From d3a9f9567dc6edbe0cb8d62adfad5c008e0d6878 Mon Sep 17 00:00:00 2001 From: Sujith H Date: Wed, 4 Oct 2017 18:27:30 +0530 Subject: [PATCH] Cleanup alternate storage location keys of user This is to make sure that there are no user specific folders if the keys are stored in alternate location apart from the default location, when a user is deleted. Hence the keys inside user folder in the alternate location would be deleted. Signed-off-by: Sujith H --- lib/Hooks/UserHooks.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/Hooks/UserHooks.php b/lib/Hooks/UserHooks.php index 24739f63..5846b7b2 100644 --- a/lib/Hooks/UserHooks.php +++ b/lib/Hooks/UserHooks.php @@ -198,8 +198,16 @@ public function postCreateUser($params) { public function postDeleteUser($params) { if (App::isEnabled('encryption')) { - $this->keyManager->deletePublicKey($params['uid']); + /** + * Adding a safe condition to make sure the uid is not + * empty or null. + */ + if (!is_null($params['uid']) && ($params['uid'] !== '')) { + $this->keyManager->deletePublicKey($params['uid']); + \OC::$server->getEncryptionKeyStorage()->deleteAltUserStorageKeys($params['uid']); + } } + } /**