summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJörn Friedrich Dreyer <jfd@butonic.de>2017-01-20 10:46:29 +0100
committerMorris Jobke <hey@morrisjobke.de>2017-04-26 01:08:53 -0300
commitfff6d6e3e8f5f74df5076bba068f85e0f67a0c0e (patch)
tree64f9815358561fb58dc33a987ce830233acda2b4 /lib
parent215573fe3ceecd701079961b598fbae9871da07b (diff)
downloadnextcloud-server-fff6d6e3e8f5f74df5076bba068f85e0f67a0c0e.tar.gz
nextcloud-server-fff6d6e3e8f5f74df5076bba068f85e0f67a0c0e.zip
Refactor auth methods
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/legacy/api.php19
-rw-r--r--lib/private/legacy/user.php5
2 files changed, 10 insertions, 14 deletions
diff --git a/lib/private/legacy/api.php b/lib/private/legacy/api.php
index 17ee9c5d468..894aee28560 100644
--- a/lib/private/legacy/api.php
+++ b/lib/private/legacy/api.php
@@ -332,25 +332,20 @@ 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());
+ if ($userSession->tryTokenLogin($request)
+ || $userSession->tryBasicAuthLogin($request, \OC::$server->getBruteForceThrottler())) {
+ self::$logoutRequired = true;
+ } else {
+ return false;
}
- } catch (\OC\User\LoginException $e) {
- 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;
}
-
- return false;
}
/**
diff --git a/lib/private/legacy/user.php b/lib/private/legacy/user.php
index 621ea3535b1..7e7cbab3bce 100644
--- a/lib/private/legacy/user.php
+++ b/lib/private/legacy/user.php
@@ -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