Merge pull request #4430 from nextcloud/refactor-auth

Improve readability of login logic
This commit is contained in:
Roeland Jago Douma 2017-04-26 10:41:53 +02:00 committed by GitHub
commit 5b5c3a1773
2 changed files with 10 additions and 14 deletions

View File

@ -332,26 +332,21 @@ class OC_API {
$userSession = \OC::$server->getUserSession();
$request = \OC::$server->getRequest();
try {
$loginSuccess = $userSession->tryTokenLogin($request);
if (!$loginSuccess) {
$loginSuccess = $userSession->tryBasicAuthLogin($request, \OC::$server->getBruteForceThrottler());
}
} catch (\OC\User\LoginException $e) {
if ($userSession->tryTokenLogin($request)
|| $userSession->tryBasicAuthLogin($request, \OC::$server->getBruteForceThrottler())) {
self::$logoutRequired = true;
} else {
return false;
}
if ($loginSuccess === true) {
self::$logoutRequired = true;
// initialize the user's filesystem
\OC_Util::setupFS(\OC_User::getUser());
self::$isLoggedIn = true;
return \OC_User::getUser();
}
} catch (\OC\User\LoginException $e) {
return false;
}
}
/**
* respond to a call

View File

@ -199,9 +199,10 @@ class OC_User {
if($setUidAsDisplayName) {
self::setDisplayName($uid);
}
self::getUserSession()->setLoginName($uid);
$userSession = self::getUserSession();
$userSession->setLoginName($uid);
$request = OC::$server->getRequest();
self::getUserSession()->createSessionToken($request, $uid, $uid);
$userSession->createSessionToken($request, $uid, $uid);
// setup the filesystem
OC_Util::setupFS($uid);
// first call the post_login hooks, the login-process needs to be