mirror of
https://github.com/delight-im/PHP-Auth.git
synced 2025-08-04 15:17:28 +02:00
Move method 'validatePassword' from class 'Auth' to 'UserManager'
This commit is contained in:
21
src/Auth.php
21
src/Auth.php
@@ -271,27 +271,6 @@ final class Auth extends UserManager {
|
|||||||
$this->authenticateUserInternal($password, null, $username, $rememberDuration);
|
$this->authenticateUserInternal($password, null, $username, $rememberDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Validates a password
|
|
||||||
*
|
|
||||||
* @param string $password the password to validate
|
|
||||||
* @return string the password if it's valid
|
|
||||||
* @throws InvalidPasswordException if the password was invalid
|
|
||||||
*/
|
|
||||||
private static function validatePassword($password) {
|
|
||||||
if (empty($password)) {
|
|
||||||
throw new InvalidPasswordException();
|
|
||||||
}
|
|
||||||
|
|
||||||
$password = trim($password);
|
|
||||||
|
|
||||||
if (strlen($password) < 1) {
|
|
||||||
throw new InvalidPasswordException();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $password;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new directive keeping the user logged in ("remember me")
|
* Creates a new directive keeping the user logged in ("remember me")
|
||||||
*
|
*
|
||||||
|
@@ -86,6 +86,27 @@ abstract class UserManager {
|
|||||||
return $email;
|
return $email;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates a password
|
||||||
|
*
|
||||||
|
* @param string $password the password to validate
|
||||||
|
* @return string the password if it's valid
|
||||||
|
* @throws InvalidPasswordException if the password was invalid
|
||||||
|
*/
|
||||||
|
protected static function validatePassword($password) {
|
||||||
|
if (empty($password)) {
|
||||||
|
throw new InvalidPasswordException();
|
||||||
|
}
|
||||||
|
|
||||||
|
$password = trim($password);
|
||||||
|
|
||||||
|
if (strlen($password) < 1) {
|
||||||
|
throw new InvalidPasswordException();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $password;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Throttles the specified action for the user to protect against too many requests
|
* Throttles the specified action for the user to protect against too many requests
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user