Commit efd03f8b authored by Jacob Priddy's avatar Jacob Priddy 👌

Don't let users delete themselves

parent 2c4708f8
......@@ -5,6 +5,7 @@ namespace Source\UseCases\Users\DeleteUser;
use Source\Authorization\Authorizer;
use Source\Gateways\Users\UsersRepository;
use Source\Exceptions\DeleteFailedException;
use Source\Exceptions\AuthorizationException;
use Source\Exceptions\EntityNotFoundException;
class DeleteUser implements DeleteUserUseCase
......@@ -32,6 +33,10 @@ class DeleteUser implements DeleteUserUseCase
{
$this->authorizer->protectAdminRights($userId);
if ($this->authorizer->getCurrentUserId() === $userId) {
throw new AuthorizationException('You cannot delete yourself!');
}
$user = $this->usersRepository->get($userId);
if (!$user) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment