diff options
author | Sandro Lutz <sandro.lutz@temparus.ch> | 2017-02-07 00:12:45 +0100 |
---|---|---|
committer | Sandro Lutz <sandro.lutz@temparus.ch> | 2017-02-07 00:15:30 +0100 |
commit | fa1d607bfa951711a2c358f889db56962c179153 (patch) | |
tree | 904b6bd3b7f9d2ed133f64da22b3fb9bbfbf1842 /lib/private/User | |
parent | ff3fa538e43bb38a5ff142b07216b9de79645c01 (diff) | |
parent | b55f5af7eaab6f827989407fa7b8d51cbb877eab (diff) | |
download | nextcloud-server-fa1d607bfa951711a2c358f889db56962c179153.tar.gz nextcloud-server-fa1d607bfa951711a2c358f889db56962c179153.zip |
Merge remote-tracking branch 'nextcloud/master'
Signed-off-by: Sandro Lutz <sandro.lutz@temparus.ch>
Diffstat (limited to 'lib/private/User')
-rw-r--r-- | lib/private/User/Database.php | 6 | ||||
-rw-r--r-- | lib/private/User/Session.php | 7 | ||||
-rw-r--r-- | lib/private/User/User.php | 10 |
3 files changed, 18 insertions, 5 deletions
diff --git a/lib/private/User/Database.php b/lib/private/User/Database.php index 28cb3302858..a281572ad55 100644 --- a/lib/private/User/Database.php +++ b/lib/private/User/Database.php @@ -238,6 +238,12 @@ class Database extends Backend implements IUserBackend { */ private function loadUser($uid) { if (!isset($this->cache[$uid])) { + //guests $uid could be NULL or '' + if ($uid === null || $uid === '') { + $this->cache[$uid]=false; + return true; + } + $query = \OC_DB::prepare('SELECT `uid`, `displayname` FROM `*PREFIX*users` WHERE LOWER(`uid`) = LOWER(?)'); $result = $query->execute(array($uid)); diff --git a/lib/private/User/Session.php b/lib/private/User/Session.php index 36bd45521cf..2ebe895a592 100644 --- a/lib/private/User/Session.php +++ b/lib/private/User/Session.php @@ -317,7 +317,7 @@ class Session implements IUserSession, Emitter { $password, IRequest $request, OC\Security\Bruteforce\Throttler $throttler) { - $currentDelay = $throttler->sleepDelay($request->getRemoteAddress()); + $currentDelay = $throttler->sleepDelay($request->getRemoteAddress(), 'login'); if ($this->manager instanceof PublicEmitter) { $this->manager->emit('\OC\User', 'preLogin', array($user, $password)); @@ -338,7 +338,7 @@ class Session implements IUserSession, Emitter { $throttler->registerAttempt('login', $request->getRemoteAddress(), ['uid' => $user]); if($currentDelay === 0) { - $throttler->sleepDelay($request->getRemoteAddress()); + $throttler->sleepDelay($request->getRemoteAddress(), 'login'); } return false; } @@ -744,6 +744,7 @@ class Session implements IUserSession, Emitter { //login $this->setUser($user); + $this->setLoginName($this->tokenProvider->getToken($sessionId)->getLoginName()); $user->updateLastLoginTimestamp(); $this->manager->emit('\OC\User', 'postRememberedLogin', [$user]); return true; @@ -768,7 +769,7 @@ class Session implements IUserSession, Emitter { try { $this->tokenProvider->invalidateToken($this->session->getId()); } catch (SessionNotAvailableException $ex) { - + } } $this->setUser(null); diff --git a/lib/private/User/User.php b/lib/private/User/User.php index 3cc6dc3b7ed..c37bb59028e 100644 --- a/lib/private/User/User.php +++ b/lib/private/User/User.php @@ -197,6 +197,8 @@ class User implements IUser { if ($this->emitter) { $this->emitter->emit('\OC\User', 'preDelete', array($this)); } + // get the home now because it won't return it after user deletion + $homePath = $this->getHome(); $result = $this->backend->deleteUser($this->uid); if ($result) { @@ -210,7 +212,11 @@ class User implements IUser { \OC::$server->getConfig()->deleteAllUserValues($this->uid); // Delete user files in /data/ - \OC_Helper::rmdirr($this->getHome()); + if ($homePath !== false) { + // FIXME: this operates directly on FS, should use View instead... + // also this is not testable/mockable... + \OC_Helper::rmdirr($homePath); + } // Delete the users entry in the storage table Storage::remove('home::' . $this->uid); @@ -261,7 +267,7 @@ class User implements IUser { if ($this->backend->implementsActions(Backend::GET_HOME) and $home = $this->backend->getHome($this->uid)) { $this->home = $home; } elseif ($this->config) { - $this->home = $this->config->getSystemValue('datadirectory') . '/' . $this->uid; + $this->home = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/' . $this->uid; } else { $this->home = \OC::$SERVERROOT . '/data/' . $this->uid; } |