Remove account data on user deletion

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2017-05-15 13:30:52 +02:00
parent cd79eb1b2c
commit 975e572a3d
No known key found for this signature in database
GPG Key ID: E166FD8976B3BAC8
2 changed files with 18 additions and 0 deletions

View File

@ -113,6 +113,19 @@ class AccountManager {
}
}
/**
* delete user from accounts table
*
* @param IUser $user
*/
public function deleteUser(IUser $user) {
$uid = $user->getUID();
$query = $this->connection->getQueryBuilder();
$query->delete($this->table)
->where($query->expr()->eq('uid', $query->createNamedParameter($uid)))
->execute();
}
/**
* get stored data from a given user
*

View File

@ -30,6 +30,7 @@
namespace OC\User;
use OC\Accounts\AccountManager;
use OC\Files\Cache\Storage;
use OC\Hooks\Emitter;
use OC_Helper;
@ -235,6 +236,10 @@ class User implements IUser {
$notification->setUser($this->uid);
\OC::$server->getNotificationManager()->markProcessed($notification);
/** @var AccountManager $accountManager */
$accountManager = \OC::$server->query(AccountManager::class);
$accountManager->deleteUser($this);
if ($this->emitter) {
$this->emitter->emit('\OC\User', 'postDelete', array($this));
}