codeigniter4 / shield

Authentication and Authorization for CodeIgniter 4
https://shield.codeigniter.com
MIT License
366 stars 133 forks source link

Bug: findByCredentials() returns User when email is empty string #546

Closed sammyskills closed 1 year ago

sammyskills commented 1 year ago

PHP Version

7.4

CodeIgniter4 Version

4.2.10

Shield Version

develop

Which operating systems have you tested for this bug?

Windows

Which server did you use?

apache

Database

MariaDB 10.4.18

Did you customize Shield?

No.

What happened?

findByCredentials() returns a valid user object when the email parameter value is empty.

Steps to Reproduce

Do this:

$users = model(UserModel);
$user = $users->findByCredentials(['email' => '']);
dd($user);

This returns a valid CodeIgniter\Shield\Entities\User instance.

Expected Output

I expect null to be returned as no email address was entered in the value field.

Anything else?

However, if I add a space with the value like so: $user = $users->findByCredentials(['email' => ' ']);, I get null.

kenjis commented 1 year ago

Thank you for reporting. I sent a PR #548