diff options
author | Vincent Petry <pvince81@owncloud.com> | 2016-06-09 16:28:06 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2016-06-09 16:28:06 +0200 |
commit | 6ba18934e6f095de08bec7bdc10c45485eeb5cc7 (patch) | |
tree | 35f0b0e84da656ef0a7cf3975b5ba05e301149d4 | |
parent | ac163426ef3db18a603c07f0e2b24f00e1cdc673 (diff) | |
parent | f20c617154cbc6d53bc52a4e81129dd4e0e22a70 (diff) | |
download | nextcloud-server-6ba18934e6f095de08bec7bdc10c45485eeb5cc7.tar.gz nextcloud-server-6ba18934e6f095de08bec7bdc10c45485eeb5cc7.zip |
Merge pull request #25000 from owncloud/fix-email-login-dav
Allow login by email address via webdav as well
-rw-r--r-- | apps/dav/lib/Connector/Sabre/Auth.php | 4 | ||||
-rw-r--r-- | lib/private/User/Session.php | 17 | ||||
-rw-r--r-- | lib/private/legacy/api.php | 4 |
3 files changed, 18 insertions, 7 deletions
diff --git a/apps/dav/lib/Connector/Sabre/Auth.php b/apps/dav/lib/Connector/Sabre/Auth.php index 7b959a0d899..27900cc1cad 100644 --- a/apps/dav/lib/Connector/Sabre/Auth.php +++ b/apps/dav/lib/Connector/Sabre/Auth.php @@ -110,10 +110,10 @@ class Auth extends AbstractBasic { $this->session->close(); return true; } else { - \OC_Util::setUpFS(); //login hooks may need early access to the filesystem + \OC_Util::setupFS(); //login hooks may need early access to the filesystem if($this->userSession->logClientIn($username, $password)) { $this->userSession->createSessionToken($this->request, $this->userSession->getUser()->getUID(), $username, $password); - \OC_Util::setUpFS($this->userSession->getUser()->getUID()); + \OC_Util::setupFS($this->userSession->getUser()->getUID()); $this->session->set(self::DAV_AUTHENTICATED, $this->userSession->getUser()->getUID()); $this->session->close(); return true; diff --git a/lib/private/User/Session.php b/lib/private/User/Session.php index e1ede95e2ae..f560bb4bfc0 100644 --- a/lib/private/User/Session.php +++ b/lib/private/User/Session.php @@ -361,7 +361,14 @@ class Session implements IUserSession, Emitter { // TODO: throw LoginException instead (https://github.com/owncloud/core/pull/24616) return false; } - return $this->login($user, $password); + if (!$this->login($user, $password) ) { + $users = $this->manager->getByEmail($user); + if (count($users) === 1) { + return $this->login($users[0]->getUID(), $password); + } + return false; + } + return true; } private function isTokenAuthEnforced() { @@ -376,7 +383,11 @@ class Session implements IUserSession, Emitter { ); $user = $this->manager->get($username); if (is_null($user)) { - return true; + $users = $this->manager->getByEmail($username); + if (count($users) !== 1) { + return true; + } + $user = $users[0]; } // DI not possible due to cyclic dependencies :'-/ return OC::$server->getTwoFactorAuthManager()->isTwoFactorAuthenticated($user); @@ -385,7 +396,7 @@ class Session implements IUserSession, Emitter { /** * Check if the given 'password' is actually a device token * - * @param type $password + * @param string $password * @return boolean */ public function isTokenPassword($password) { diff --git a/lib/private/legacy/api.php b/lib/private/legacy/api.php index 1e581153ce6..024f3c0fb63 100644 --- a/lib/private/legacy/api.php +++ b/lib/private/legacy/api.php @@ -349,7 +349,7 @@ class OC_API { if ($ocsApiRequest) { // initialize the user's filesystem - \OC_Util::setUpFS(\OC_User::getUser()); + \OC_Util::setupFS(\OC_User::getUser()); self::$isLoggedIn = true; return OC_User::getUser(); @@ -374,7 +374,7 @@ class OC_API { self::$logoutRequired = true; // initialize the user's filesystem - \OC_Util::setUpFS(\OC_User::getUser()); + \OC_Util::setupFS(\OC_User::getUser()); self::$isLoggedIn = true; return \OC_User::getUser(); |