mirror of
https://github.com/delight-im/PHP-Auth.git
synced 2025-08-05 07:37:25 +02:00
Re-use 'getUserDataByEmailAddress' in 'authenticateUserInternal'
This commit is contained in:
25
src/Auth.php
25
src/Auth.php
@@ -772,17 +772,23 @@ class Auth {
|
|||||||
private function authenticateUserInternal($password, $email, $rememberDuration = null) {
|
private function authenticateUserInternal($password, $email, $rememberDuration = null) {
|
||||||
$email = self::validateEmailAddress($email);
|
$email = self::validateEmailAddress($email);
|
||||||
|
|
||||||
|
// attempt to look up the account information using the specified email address
|
||||||
try {
|
try {
|
||||||
$userData = $this->db->selectRow(
|
$userData = $this->getUserDataByEmailAddress(
|
||||||
'SELECT id, email, password, verified, username FROM users WHERE email = ?',
|
$email,
|
||||||
[ $email ]
|
[ 'id', 'email', 'password', 'verified', 'username' ]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
catch (Error $e) {
|
// if there is no user with the specified email address
|
||||||
throw new DatabaseError();
|
catch (InvalidEmailException $e) {
|
||||||
|
// throttle this operation
|
||||||
|
$this->throttle(self::THROTTLE_ACTION_LOGIN);
|
||||||
|
$this->throttle(self::THROTTLE_ACTION_LOGIN, $email);
|
||||||
|
|
||||||
|
// and re-throw the exception
|
||||||
|
throw new InvalidEmailException();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($userData)) {
|
|
||||||
$password = self::validatePassword($password);
|
$password = self::validatePassword($password);
|
||||||
|
|
||||||
if (password_verify($password, $userData['password'])) {
|
if (password_verify($password, $userData['password'])) {
|
||||||
@@ -820,13 +826,6 @@ class Auth {
|
|||||||
throw new InvalidPasswordException();
|
throw new InvalidPasswordException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
$this->throttle(self::THROTTLE_ACTION_LOGIN);
|
|
||||||
$this->throttle(self::THROTTLE_ACTION_LOGIN, $email);
|
|
||||||
|
|
||||||
throw new InvalidEmailException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the requested user data for the account with the specified email address (if any)
|
* Returns the requested user data for the account with the specified email address (if any)
|
||||||
|
Reference in New Issue
Block a user