From 7498e47fed115ef5726b0ad7a4837a73aa2b4ba7 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 25 Aug 2022 11:04:16 +0900 Subject: [PATCH 1/4] fix: for OCI8 driver --- src/Models/LoginModel.php | 2 ++ src/Models/UserModel.php | 6 ++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Models/LoginModel.php b/src/Models/LoginModel.php index 08bf3011d..b550e90cc 100644 --- a/src/Models/LoginModel.php +++ b/src/Models/LoginModel.php @@ -56,6 +56,8 @@ public function recordLoginAttempt( ?string $userAgent = null, $userId = null ): void { + $this->disableDBDebug(); + $return = $this->insert([ 'ip_address' => $ipAddress, 'user_agent' => $userAgent, diff --git a/src/Models/UserModel.php b/src/Models/UserModel.php index 3deb23a6e..b34f87144 100644 --- a/src/Models/UserModel.php +++ b/src/Models/UserModel.php @@ -169,18 +169,16 @@ public function findByCredentials(array $credentials): ?User $email = $credentials['email'] ?? null; unset($credentials['email']); - $prefix = $this->db->DBPrefix; - // any of the credentials used should be case-insensitive foreach ($credentials as $key => $value) { - $this->where("LOWER({$prefix}users.{$key})", strtolower($value)); + $this->where('LOWER(' . $this->db->protectIdentifiers("users.{$key}") . ')', strtolower($value)); } if (! empty($email)) { $data = $this->select('users.*, auth_identities.secret as email, auth_identities.secret2 as password_hash') ->join('auth_identities', 'auth_identities.user_id = users.id') ->where('auth_identities.type', Session::ID_TYPE_EMAIL_PASSWORD) - ->where("LOWER({$prefix}auth_identities.secret)", strtolower($email)) + ->where('LOWER(' . $this->db->protectIdentifiers('auth_identities.secret') . ')', strtolower($email)) ->asArray() ->first(); From e9a2336e4b66a17e3a8ef427df489c2d58126057 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 25 Aug 2022 11:36:04 +0900 Subject: [PATCH 2/4] fix: set property cast for AccessToken::$id --- src/Entities/AccessToken.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Entities/AccessToken.php b/src/Entities/AccessToken.php index 1bc0cfab7..b93670bac 100644 --- a/src/Entities/AccessToken.php +++ b/src/Entities/AccessToken.php @@ -20,6 +20,7 @@ class AccessToken extends Entity * @var array */ protected $casts = [ + 'id' => '?integer', 'last_used_at' => 'datetime', 'extra' => 'array', 'expires' => 'datetime', From 4bd544b2fb1d5f55cdc7f4a62bbef13d476a6522 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 25 Aug 2022 12:02:40 +0900 Subject: [PATCH 3/4] fix: set property cast for UserIdentity::$id --- src/Entities/UserIdentity.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Entities/UserIdentity.php b/src/Entities/UserIdentity.php index 6ddff1c18..011aa524a 100644 --- a/src/Entities/UserIdentity.php +++ b/src/Entities/UserIdentity.php @@ -26,6 +26,7 @@ class UserIdentity extends Entity * @var array */ protected $casts = [ + 'id' => '?integer', 'force_reset' => 'int_bool', ]; From 75c37d0de32937b258156a8819478062111d5f16 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 25 Aug 2022 13:01:47 +0900 Subject: [PATCH 4/4] fix: add hack to insert error with OCI8 Query error: 1400, ORA-01400: cannot insert NULL into ("ORACLE"."db_auth_logins"."identifier"), query: INSERT INTO "db_auth_logins" ("ip_address", "user_agent", "id_type", "identifier", "user_id", "date", "success") VALUES ('0.0.0.0', '', 'email_password', '', NULL, '2022-08-24 22:10:33', 0) --- src/Models/LoginModel.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Models/LoginModel.php b/src/Models/LoginModel.php index b550e90cc..80185030b 100644 --- a/src/Models/LoginModel.php +++ b/src/Models/LoginModel.php @@ -58,6 +58,10 @@ public function recordLoginAttempt( ): void { $this->disableDBDebug(); + if ($this->db->getPlatform() === 'OCI8' && $identifier === '') { + $identifier = ' '; + } + $return = $this->insert([ 'ip_address' => $ipAddress, 'user_agent' => $userAgent,