From 4d5066f5da1b12928cda5e852152d1f057896b1a Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Tue, 20 Mar 2018 22:48:38 +0100 Subject: [PATCH] app/library/Auth/Auth.php: in login() accept both username and email. --- app/library/Auth/Auth.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/library/Auth/Auth.php b/app/library/Auth/Auth.php index faecb4a..3f76c88 100644 --- a/app/library/Auth/Auth.php +++ b/app/library/Auth/Auth.php @@ -12,13 +12,19 @@ class Auth extends Component */ protected $_session_key = 'auth'; - public function login($email, $password) + /** + * Login using email/user + password combination. + * + * @param string $email_username + * @param string $password + * @return bool + */ + public function login($email_username, $password) { - // Look for a user with this email. - $user = User::findFirstByEmail($email); + // Look for a user with this username/email. + $user = User::findFirstByUsernameOrEmail($email_username); if ($user) { - // Verify password $hash = $user->getPassword(); if (strlen($hash) > 1 && password_verify($password, $hash)) {