1
0
mirror of https://github.com/delight-im/PHP-Auth.git synced 2025-10-23 03:46:08 +02:00

Add public method 'loginWithUsername' to class 'Auth'

This commit is contained in:
Marco
2017-02-20 21:36:45 +01:00
parent 690485ba6d
commit 3cb2284870
2 changed files with 23 additions and 1 deletions

View File

@@ -254,7 +254,7 @@ class Auth {
}
/**
* Attempts to sign in a user
* Attempts to sign in a user with their email address and password
*
* @param string $email the user's email address
* @param string $password the user's password
@@ -268,6 +268,26 @@ class Auth {
$this->authenticateUserInternal($password, $email, null, $rememberDuration);
}
/**
* Attempts to sign in a user with their username and password
*
* When using this method to authenticate users, you should ensure that usernames are unique
*
* Consistently using {@see registerWithUniqueUsername} instead of {@see register} can be helpful
*
* @param string $username the user's username
* @param string $password the user's password
* @param int|bool|null $rememberDuration (optional) the duration in seconds to keep the user logged in ("remember me"), e.g. `60 * 60 * 24 * 365.25` for one year
* @throws UnknownUsernameException if the specified username does not exist
* @throws AmbiguousUsernameException if the specified username is ambiguous, i.e. there are multiple users with that name
* @throws InvalidPasswordException if the password was invalid
* @throws EmailNotVerifiedException if the email address has not been verified yet via confirmation email
* @throws AuthError if an internal problem occurred (do *not* catch)
*/
public function loginWithUsername($username, $password, $rememberDuration = null) {
$this->authenticateUserInternal($password, null, $username, $rememberDuration);
}
/**
* Validates an email address
*