summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Schießle <bjoern@schiessle.org>2013-10-29 09:46:21 -0700
committerBjörn Schießle <bjoern@schiessle.org>2013-10-29 09:46:21 -0700
commite08f38f99babcd16701583e789838ccd9376401a (patch)
tree464aa38436ef3b521eb57caa9c5cb84804b66edf
parente0bc89c87ff0bf51e0a3ba6537fa71500e10df28 (diff)
parentf021dad204afab2977417265f121d660d3d71252 (diff)
downloadnextcloud-server-e08f38f99babcd16701583e789838ccd9376401a.tar.gz
nextcloud-server-e08f38f99babcd16701583e789838ccd9376401a.zip
Merge pull request #5605 from owncloud/fix_delete_user
remove user from cache if he was deleted successfully
-rw-r--r--lib/private/user.php25
-rw-r--r--lib/private/user/manager.php14
2 files changed, 30 insertions, 9 deletions
diff --git a/lib/private/user.php b/lib/private/user.php
index 6b350d4cf1b..710f0fd66db 100644
--- a/lib/private/user.php
+++ b/lib/private/user.php
@@ -187,18 +187,25 @@ class OC_User {
public static function deleteUser($uid) {
$user = self::getManager()->get($uid);
if ($user) {
- $user->delete();
+ $result = $user->delete();
- // We have to delete the user from all groups
- foreach (OC_Group::getUserGroups($uid) as $i) {
- OC_Group::removeFromGroup($uid, $i);
+ // if delete was successful we clean-up the rest
+ if ($result) {
+
+ // We have to delete the user from all groups
+ foreach (OC_Group::getUserGroups($uid) as $i) {
+ OC_Group::removeFromGroup($uid, $i);
+ }
+ // Delete the user's keys in preferences
+ OC_Preferences::deleteUser($uid);
+
+ // Delete user files in /data/
+ OC_Helper::rmdirr(OC_Config::getValue('datadirectory', OC::$SERVERROOT . '/data') . '/' . $uid . '/');
+
+ // Remove it from the Cache
+ self::getManager()->delete($uid);
}
- // Delete the user's keys in preferences
- OC_Preferences::deleteUser($uid);
- // Delete user files in /data/
- OC_Helper::rmdirr(OC_Config::getValue('datadirectory', OC::$SERVERROOT . '/data') . '/' . $uid . '/');
-
return true;
} else {
return false;
diff --git a/lib/private/user/manager.php b/lib/private/user/manager.php
index 13286bc28a4..703c8cd7413 100644
--- a/lib/private/user/manager.php
+++ b/lib/private/user/manager.php
@@ -119,6 +119,20 @@ class Manager extends PublicEmitter {
}
/**
+ * remove deleted user from cache
+ *
+ * @param string $uid
+ * @return bool
+ */
+ public function delete($uid) {
+ if (isset($this->cachedUsers[$uid])) {
+ unset($this->cachedUsers[$uid]);
+ return true;
+ }
+ return false;
+ }
+
+ /**
* Check if the password is valid for the user
*
* @param $loginname