mirror of
https://github.com/delight-im/PHP-Auth.git
synced 2025-08-03 06:37:27 +02:00
No need to check for uniqueness of username if none has been provided
This commit is contained in:
21
src/Auth.php
21
src/Auth.php
@@ -719,16 +719,19 @@ class Auth {
|
|||||||
|
|
||||||
// if the uniqueness of the username is to be ensured
|
// if the uniqueness of the username is to be ensured
|
||||||
if ($requireUniqueUsername) {
|
if ($requireUniqueUsername) {
|
||||||
// count the number of users who do already have that specified username
|
// if a username has actually been provided
|
||||||
$occurrencesOfUsername = $this->db->selectValue(
|
if ($username !== null) {
|
||||||
'SELECT COUNT(*) FROM users WHERE username = ?',
|
// count the number of users who do already have that specified username
|
||||||
[ $username ]
|
$occurrencesOfUsername = $this->db->selectValue(
|
||||||
);
|
'SELECT COUNT(*) FROM users WHERE username = ?',
|
||||||
|
[ $username ]
|
||||||
|
);
|
||||||
|
|
||||||
// if any user with that username does already exist
|
// if any user with that username does already exist
|
||||||
if ($occurrencesOfUsername > 0) {
|
if ($occurrencesOfUsername > 0) {
|
||||||
// cancel the operation and report the violation of this requirement
|
// cancel the operation and report the violation of this requirement
|
||||||
throw new DuplicateUsernameException();
|
throw new DuplicateUsernameException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user