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:
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 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
|
* Validates a password
|
||||||
*
|
*
|
||||||
|
@@ -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
|
* Throttles the specified action for the user to protect against too many requests
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user