From c68bc08474fb3a993e652cf8671e096f88813470 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Fri, 13 Jan 2017 17:02:41 +0100 Subject: [PATCH] Use preDelete hook to delete encryption keys (#26938) Because we sometimes need to mount the user's home before deleting encryption keys, this must happen in a preDelete hook because the postDelete is too late. In postDelete the user's home already doesn't exist any more and cannot be mounted. --- apps/encryption/lib/Hooks/UserHooks.php | 6 +++--- apps/encryption/tests/Hooks/UserHooksTest.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/encryption/lib/Hooks/UserHooks.php b/apps/encryption/lib/Hooks/UserHooks.php index d189ce3eeeffb..65d8c24ee8a7d 100644 --- a/apps/encryption/lib/Hooks/UserHooks.php +++ b/apps/encryption/lib/Hooks/UserHooks.php @@ -155,9 +155,9 @@ public function addHooks() { 'postCreateUser'); OCUtil::connectHook('OC_User', - 'post_deleteUser', + 'pre_deleteUser', $this, - 'postDeleteUser'); + 'preDeleteUser'); } } @@ -212,7 +212,7 @@ public function postCreateUser($params) { * @param array $params : uid, password * @note This method should never be called for users using client side encryption */ - public function postDeleteUser($params) { + public function preDeleteUser($params) { if (App::isEnabled('encryption')) { $this->keyManager->deletePublicKey($params['uid']); diff --git a/apps/encryption/tests/Hooks/UserHooksTest.php b/apps/encryption/tests/Hooks/UserHooksTest.php index f9477e3e03856..0b8bd63e14376 100644 --- a/apps/encryption/tests/Hooks/UserHooksTest.php +++ b/apps/encryption/tests/Hooks/UserHooksTest.php @@ -111,12 +111,12 @@ public function testPostCreateUser() { $this->assertTrue(true); } - public function testPostDeleteUser() { + public function testPreDeleteUser() { $this->keyManagerMock->expects($this->once()) ->method('deletePublicKey') ->with('testUser'); - $this->instance->postDeleteUser($this->params); + $this->instance->preDeleteUser($this->params); $this->assertTrue(true); }