1
0
mirror of https://github.com/delight-im/PHP-Auth.git synced 2025-08-04 15:17:28 +02:00

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

This commit is contained in:
Marco
2017-02-21 09:17:08 +01:00
parent e916c3d07e
commit f7d50d53ea
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 an email address
*
* @param string $email the email address to validate
* @return string the email address if it's valid
* @throws InvalidEmailException if the email address was invalid
*/
private static function validateEmailAddress($email) {
if (empty($email)) {
throw new InvalidEmailException();
}
$email = trim($email);
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
throw new InvalidEmailException();
}
return $email;
}
/**
* Validates a password
*

View File

@@ -65,6 +65,27 @@ abstract class UserManager {
}
}
/**
* Validates an email address
*
* @param string $email the email address to validate
* @return string the email address if it's valid
* @throws InvalidEmailException if the email address was invalid
*/
protected static function validateEmailAddress($email) {
if (empty($email)) {
throw new InvalidEmailException();
}
$email = trim($email);
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
throw new InvalidEmailException();
}
return $email;
}
/**
* Throttles the specified action for the user to protect against too many requests
*