summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-05-02 14:51:01 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2016-05-02 14:51:01 +0200
commit7aca13f14c2974a5e3f78cff628209c3964aaf04 (patch)
tree1d4ca6c26c5dd9eeca66ed54d6d5406642796d54 /lib
parentb10dcfc3b7e84c97d4dba4f7c63b4dff2fbc310b (diff)
downloadnextcloud-server-7aca13f14c2974a5e3f78cff628209c3964aaf04.tar.gz
nextcloud-server-7aca13f14c2974a5e3f78cff628209c3964aaf04.zip
Allow login by email address
Diffstat (limited to 'lib')
-rw-r--r--lib/private/legacy/user.php14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/private/legacy/user.php b/lib/private/legacy/user.php
index 11c35daa0de..78eb4bab126 100644
--- a/lib/private/legacy/user.php
+++ b/lib/private/legacy/user.php
@@ -152,14 +152,22 @@ class OC_User {
/**
* Try to login a user
*
- * @param string $loginname The login name of the user to log in
+ * @param string $loginName The login name of the user to log in
* @param string $password The password of the user
* @return boolean|null
*
* Log in a user and regenerate a new session - if the password is ok
*/
- public static function login($loginname, $password) {
- $result = self::getUserSession()->login($loginname, $password);
+ public static function login($loginName, $password) {
+
+ $result = self::getUserSession()->login($loginName, $password);
+ if (!$result) {
+ $users = \OC::$server->getUserManager()->getByEmail($loginName);
+ // we only allow login by email if unique
+ if (count($users) === 1) {
+ $result = self::getUserSession()->login($users[0]->getUID(), $password);
+ }
+ }
if ($result) {
// Refresh the token
\OC::$server->getCsrfTokenManager()->refreshToken();