1
0
mirror of https://github.com/delight-im/PHP-Auth.git synced 2025-08-03 22:57:27 +02:00

Move method 'validatePassword' from class 'Auth' to 'UserManager'

This commit is contained in:
Marco
2017-02-21 09:19:09 +01:00
parent f7d50d53ea
commit ad2aa84e4a
2 changed files with 21 additions and 21 deletions

View File

@@ -271,27 +271,6 @@ final class Auth extends UserManager {
$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")
*

View File

@@ -86,6 +86,27 @@ abstract class UserManager {
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
*