Remove account data on user deletion
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
cd79eb1b2c
commit
975e572a3d
|
@ -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
|
* get stored data from a given user
|
||||||
*
|
*
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
namespace OC\User;
|
namespace OC\User;
|
||||||
|
|
||||||
|
use OC\Accounts\AccountManager;
|
||||||
use OC\Files\Cache\Storage;
|
use OC\Files\Cache\Storage;
|
||||||
use OC\Hooks\Emitter;
|
use OC\Hooks\Emitter;
|
||||||
use OC_Helper;
|
use OC_Helper;
|
||||||
|
@ -235,6 +236,10 @@ class User implements IUser {
|
||||||
$notification->setUser($this->uid);
|
$notification->setUser($this->uid);
|
||||||
\OC::$server->getNotificationManager()->markProcessed($notification);
|
\OC::$server->getNotificationManager()->markProcessed($notification);
|
||||||
|
|
||||||
|
/** @var AccountManager $accountManager */
|
||||||
|
$accountManager = \OC::$server->query(AccountManager::class);
|
||||||
|
$accountManager->deleteUser($this);
|
||||||
|
|
||||||
if ($this->emitter) {
|
if ($this->emitter) {
|
||||||
$this->emitter->emit('\OC\User', 'postDelete', array($this));
|
$this->emitter->emit('\OC\User', 'postDelete', array($this));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue