From fff08a9894bd089bdaae9cf87bbe96991889fbbf Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 27 May 2011 16:35:06 -0700 Subject: [PATCH] Allow emails to be used for login Summary: Despite the form's claims that you can login with username or email, it actually accepted only username. Test Plan: Logged in using my email. Reviewed By: jungejason Reviewers: tuomaspelkonen, jungejason, aran CC: jr, anjali, aran, jungejason Differential Revision: 354 --- .../login/PhabricatorLoginController.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/applications/auth/controller/login/PhabricatorLoginController.php b/src/applications/auth/controller/login/PhabricatorLoginController.php index 1e22147785..125bfcb408 100644 --- a/src/applications/auth/controller/login/PhabricatorLoginController.php +++ b/src/applications/auth/controller/login/PhabricatorLoginController.php @@ -44,11 +44,17 @@ class PhabricatorLoginController extends PhabricatorAuthController { $error = false; $username = $request->getCookie('phusr'); if ($request->isFormPost()) { - $username = $request->getStr('username'); + $username_or_email = $request->getStr('username_or_email'); $user = id(new PhabricatorUser())->loadOneWhere( 'username = %s', - $username); + $username_or_email); + + if (!$user) { + $user = id(new PhabricatorUser())->loadOneWhere( + 'email = %s', + $username_or_email); + } $okay = false; if ($user) { @@ -91,8 +97,8 @@ class PhabricatorLoginController extends PhabricatorAuthController { ->appendChild( id(new AphrontFormTextControl()) ->setLabel('Username/Email') - ->setName('username') - ->setValue($username)) + ->setName('username_or_email') + ->setValue($username_or_email)) ->appendChild( id(new AphrontFormPasswordControl()) ->setLabel('Password')