Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Entities/AccessToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class AccessToken extends Entity
* @var array<string, string>
*/
protected $casts = [
'id' => '?integer',
'last_used_at' => 'datetime',
'extra' => 'array',
'expires' => 'datetime',
Expand Down
1 change: 1 addition & 0 deletions src/Entities/UserIdentity.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class UserIdentity extends Entity
* @var array<string, string>
*/
protected $casts = [
'id' => '?integer',
'force_reset' => 'int_bool',
];

Expand Down
6 changes: 6 additions & 0 deletions src/Models/LoginModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ public function recordLoginAttempt(
?string $userAgent = null,
$userId = null
): void {
$this->disableDBDebug();

if ($this->db->getPlatform() === 'OCI8' && $identifier === '') {
$identifier = ' ';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... and this?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see the whole commit message now, that explains this one. Seems like this is probably a bug in the framework driver itself, right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure.
Oracle sees '' as NULL.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oracle Database currently treats a character value with a length of zero as null. However, this may not continue to be true in future releases, and Oracle recommends that you do not treat empty strings the same as nulls.

More see.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@datamweb I knew it, but I don't know what should we do in this case.
We try to insert '', but Oracle treats it as NULL and says "cannot insert NULL"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use an alternate representation, such as a single space character, for an empty string.

It is what I did here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ytetsuro have any recommendations? Or @sclubricants?

}

$return = $this->insert([
'ip_address' => $ipAddress,
'user_agent' => $userAgent,
Expand Down
6 changes: 2 additions & 4 deletions src/Models/UserModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down