]> source.dussan.org Git - nextcloud-server.git/commitdiff
Remove account data on user deletion 4871/head
authorJoas Schilling <coding@schilljs.com>
Mon, 15 May 2017 11:30:52 +0000 (13:30 +0200)
committerJoas Schilling <coding@schilljs.com>
Mon, 15 May 2017 11:31:31 +0000 (13:31 +0200)
Signed-off-by: Joas Schilling <coding@schilljs.com>
lib/private/Accounts/AccountManager.php
lib/private/User/User.php

index 41fdad148aa440057f6a4ed59538f83513fe1b8c..7db686c33a137b34b631713711bc39bcd4a0b129 100644 (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
         *
index f55807bc769ef545bd9d504a8a4998c0ff887b18..5e5d3f0d772794af1a3827c84edd21c1b72b1eec 100644 (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));
                        }