From ee9a8f232b960c5bfad7376f129710d19871edcc Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Fri, 11 Sep 2015 22:01:46 +0200 Subject: Allow for logging in via email address MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Accept both user names and email addresses in the login prompt. Suggested-by: Johannes Löthberg Signed-off-by: Lukas Fleischer --- web/html/login.php | 2 +- web/lib/acctfuncs.inc.php | 2 +- web/lib/aur.inc.php | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) (limited to 'web') diff --git a/web/html/login.php b/web/html/login.php index ab7bac9..cef9be4 100644 --- a/web/html/login.php +++ b/web/html/login.php @@ -28,7 +28,7 @@ html_header('AUR ' . __("Login"));

- +

diff --git a/web/lib/acctfuncs.inc.php b/web/lib/acctfuncs.inc.php index ee8f0e3..756c847 100644 --- a/web/lib/acctfuncs.inc.php +++ b/web/lib/acctfuncs.inc.php @@ -479,7 +479,7 @@ function try_login() { } $dbh = DB::connect(); - $userID = uid_from_username($_REQUEST['user']); + $userID = uid_from_loginname($_REQUEST['user']); if (user_suspended($userID)) { $login_error = __('Account suspended'); diff --git a/web/lib/aur.inc.php b/web/lib/aur.inc.php index 7d65913..9015ae8 100644 --- a/web/lib/aur.inc.php +++ b/web/lib/aur.inc.php @@ -466,6 +466,21 @@ function uid_from_username($username) { return $row[0]; } +/** + * Determine the user's ID in the database using a username or email address + * + * @param string $username The username or email address of an account + * + * @return string Return user ID if exists, otherwise null + */ +function uid_from_loginname($loginname) { + $uid = uid_from_username($loginname); + if (!$uid) { + $uid = uid_from_email($loginname); + } + return $uid; +} + /** * Determine the user's ID in the database using an e-mail address * -- cgit v1.2.3-70-g09d2