Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion apps/encryption/lib/Hooks/UserHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,14 @@ 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']);
}
}
}

Expand Down
21 changes: 21 additions & 0 deletions lib/private/Encryption/Keys/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,27 @@ public function deleteSystemUserKey($keyId, $encryptionModuleId) {
return !$this->view->file_exists($path) || $this->view->unlink($path);
}

/**
* @inheritdoc
*/

public function deleteAltUserStorageKeys($uid) {
if (\OC::$server->getEncryptionManager()->isEnabled()) {
/**
* If the key storage is not the default
* location, then we need to remove the keys
* in the alternate key location
*/
$keyStorageRoot = $this->util->getKeyStorageRoot();
if ($keyStorageRoot !== '') {
$this->view->rmdir($keyStorageRoot . '/' . $uid);
return true;
}

return false;
}
}

/**
* construct path to users key
*
Expand Down
10 changes: 10 additions & 0 deletions lib/public/Encryption/Keys/IStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,14 @@ public function renameKeys($source, $target);
*/
public function copyKeys($source, $target);

/**
* delete user keys from alternate storage location when
* a user is deleted
*
* @param $uid
* @return boolean
* @since 10.0.4
*/
public function deleteAltUserStorageKeys($uid);

}