Skip to content

Commit 1ef3977

Browse files
authored
Merge pull request #402 from kenjis/support-other-databases
feat: support other databases
2 parents e379f79 + 75c37d0 commit 1ef3977

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

src/Entities/AccessToken.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class AccessToken extends Entity
2020
* @var array<string, string>
2121
*/
2222
protected $casts = [
23+
'id' => '?integer',
2324
'last_used_at' => 'datetime',
2425
'extra' => 'array',
2526
'expires' => 'datetime',

src/Entities/UserIdentity.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class UserIdentity extends Entity
2626
* @var array<string, string>
2727
*/
2828
protected $casts = [
29+
'id' => '?integer',
2930
'force_reset' => 'int_bool',
3031
];
3132

src/Models/LoginModel.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ public function recordLoginAttempt(
5656
?string $userAgent = null,
5757
$userId = null
5858
): void {
59+
$this->disableDBDebug();
60+
61+
if ($this->db->getPlatform() === 'OCI8' && $identifier === '') {
62+
$identifier = ' ';
63+
}
64+
5965
$return = $this->insert([
6066
'ip_address' => $ipAddress,
6167
'user_agent' => $userAgent,

src/Models/UserModel.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,18 +169,16 @@ public function findByCredentials(array $credentials): ?User
169169
$email = $credentials['email'] ?? null;
170170
unset($credentials['email']);
171171

172-
$prefix = $this->db->DBPrefix;
173-
174172
// any of the credentials used should be case-insensitive
175173
foreach ($credentials as $key => $value) {
176-
$this->where("LOWER({$prefix}users.{$key})", strtolower($value));
174+
$this->where('LOWER(' . $this->db->protectIdentifiers("users.{$key}") . ')', strtolower($value));
177175
}
178176

179177
if (! empty($email)) {
180178
$data = $this->select('users.*, auth_identities.secret as email, auth_identities.secret2 as password_hash')
181179
->join('auth_identities', 'auth_identities.user_id = users.id')
182180
->where('auth_identities.type', Session::ID_TYPE_EMAIL_PASSWORD)
183-
->where("LOWER({$prefix}auth_identities.secret)", strtolower($email))
181+
->where('LOWER(' . $this->db->protectIdentifiers('auth_identities.secret') . ')', strtolower($email))
184182
->asArray()
185183
->first();
186184

0 commit comments

Comments
 (0)