Merge pull request #5605 from owncloud/fix_delete_user
remove user from cache if he was deleted successfully
This commit is contained in:
commit
e08f38f99b
2 changed files with 30 additions and 9 deletions
|
@ -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;
|
||||
|
|
|
@ -118,6 +118,20 @@ class Manager extends PublicEmitter {
|
|||
return ($user !== null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue