]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
let users login with email address
authorEvan Prodromou <evan@status.net>
Mon, 2 May 2011 22:17:08 +0000 (15:17 -0700)
committerEvan Prodromou <evan@status.net>
Mon, 2 May 2011 22:17:08 +0000 (15:17 -0700)
actions/login.php
lib/util.php

index 7ec9c321391d1ea04994266834948f0871a36ac1..55eccf4b2c676216f19b81b51a000143deff9127 100644 (file)
@@ -228,7 +228,7 @@ class LoginAction extends Action
         $this->elementStart('ul', 'form_data');
         $this->elementStart('li');
         // TRANS: Field label on login page.
-        $this->input('nickname', _('Nickname'));
+        $this->input('nickname', _('Username or email'));
         $this->elementEnd('li');
         $this->elementStart('li');
         // TRANS: Field label on login page.
index f830d9b64300b029d7f6ecca712fba70c5254114..0b637dd1cc4efe6b9d211efe4a3bff4586a5fd36 100644 (file)
@@ -233,7 +233,13 @@ function common_check_user($nickname, $password)
     $authenticatedUser = false;
 
     if (Event::handle('StartCheckPassword', array($nickname, $password, &$authenticatedUser))) {
-        $user = User::staticGet('nickname', common_canonical_nickname($nickname));
+
+        if (common_is_email($nickname)) {
+            $user = User::staticGet('email', common_canonical_email($nickname));
+        } else {
+            $user = User::staticGet('nickname', common_canonical_nickname($nickname));
+        }
+
         if (!empty($user)) {
             if (!empty($password)) { // never allow login with blank password
                 if (0 == strcmp(common_munge_password($password, $user->id),
@@ -2297,3 +2303,8 @@ function common_log_perf_counters()
         }
     }
 }
+
+function common_is_email($str)
+{
+    return (strpos($str, '@') !== false);
+}