Merge pull request #25000 from owncloud/fix-email-login-dav

Allow login by email address via webdav as well
This commit is contained in:
Vincent Petry 2016-06-09 16:28:06 +02:00
commit 6ba18934e6
3 changed files with 18 additions and 7 deletions

View File

@ -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;

View File

@ -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) {

View File

@ -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();