diff --git a/taiga/users/api.py b/taiga/users/api.py index 79c0373f..56bee9e7 100644 --- a/taiga/users/api.py +++ b/taiga/users/api.py @@ -274,9 +274,13 @@ class UsersViewSet(ModelCrudViewSet): max_age_cancel_account = getattr(settings, "MAX_AGE_CANCEL_ACCOUNT", None) user = get_user_for_token(serializer.data["cancel_token"], "cancel_account", max_age=max_age_cancel_account) + except exc.NotAuthenticated: raise exc.WrongArguments(_("Invalid, are you sure the token is correct?")) + if not user.is_active: + raise exc.WrongArguments(_("Invalid, are you sure the token is correct?")) + user.cancel() return Response(status=status.HTTP_204_NO_CONTENT)