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', 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', ]; diff --git a/src/Models/LoginModel.php b/src/Models/LoginModel.php index 08bf3011d..80185030b 100644 --- a/src/Models/LoginModel.php +++ b/src/Models/LoginModel.php @@ -56,6 +56,12 @@ public function recordLoginAttempt( ?string $userAgent = null, $userId = null ): void { + $this->disableDBDebug(); + + if ($this->db->getPlatform() === 'OCI8' && $identifier === '') { + $identifier = ' '; + } + $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();