]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Allow login via email.
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Fri, 9 Apr 2010 22:06:52 +0000 (22:06 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Fri, 9 Apr 2010 22:06:52 +0000 (22:06 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@5678 36083f99-b078-4883-b0ff-0f9b5a30f544

actions/login.php

index 3b215da66dbc21eb5cf82702314476ce409c5a6a..fed45fbc571e88e5791406abd9de0809f0d3941f 100644 (file)
@@ -16,7 +16,13 @@ $persistent = get_input("persistent", false);
 // If all is present and correct, try to log in
 $result = false;
 if (!empty($username) && !empty($password)) {
-       if ($user = authenticate($username,$password)) {
+       // check first if this is an email address and do a login
+       // email addies will be validated
+       if (strpos($username, '@') !== FALSE && ($user=get_user_by_email($username))) {
+               $username = $user[0]->username;
+       }
+
+       if ($user = authenticate($username, $password)) {
                $result = login($user, $persistent);
        }
 }
@@ -29,7 +35,7 @@ if ($result) {
                unset($_SESSION['last_forward_from']);
                forward($forward_url);
        } else {
-               if ( (isadminloggedin()) && (!datalist_get('first_admin_login'))) {
+               if ((isadminloggedin()) && (!datalist_get('first_admin_login'))) {
                        system_message(elgg_echo('firstadminlogininstructions'));
                        datalist_set('first_admin_login', time());