Skip to content

Commit

Permalink
Delete Handler: check if owner to pgp key exists
Browse files Browse the repository at this point in the history
  • Loading branch information
y3n4 committed Apr 21, 2024
1 parent f40f804 commit 082c759
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/Handler/DeleteHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ class DeleteHandler
/**
* DeleteHandler constructor.
*/
public function __construct(private readonly PasswordUpdater $passwordUpdater, private readonly EntityManagerInterface $manager, private readonly WkdHandler $wkdHandler)
{
public function __construct(
private readonly PasswordUpdater $passwordUpdater,
private readonly EntityManagerInterface $manager,
private readonly WkdHandler $wkdHandler
) {
}

public function deleteAlias(Alias $alias, User $user = null)
Expand Down Expand Up @@ -52,12 +55,14 @@ public function deleteUser(User $user)
$user->eraseMailCryptPublicKey();
$user->eraseMailCryptSecretBox();

// Delete OpenPGP key from WKD
$this->wkdHandler->deleteKey($user->getEmail());

// Flag user as deleted
$user->setDeleted(true);

// Delete OpenPGP key from WKD if no other user owns mail handle
if (!$this->wkdHandler->userToUserIdExists($user->getEmail())) {
$this->wkdHandler->deleteKey($user->getEmail());
}

$this->manager->flush();
}
}

0 comments on commit 082c759

Please sign in to comment.