fix 404 when user not exist

This commit is contained in:
Your Name 2024-07-05 22:18:13 -04:00 committed by Henri Dickson
parent cbc4c8de77
commit 6568b2324f
2 changed files with 9 additions and 2 deletions

View file

@ -4,7 +4,7 @@ from typing import TYPE_CHECKING
from discord import SyncWebhook
from django.conf import settings
from django.core.exceptions import PermissionDenied
from django.core.exceptions import ObjectDoesNotExist, PermissionDenied
from django.core.signing import b62_decode, b62_encode
from django.http import Http404, HttpRequest, HttpResponseRedirect, QueryDict
from django.utils import timezone
@ -87,7 +87,7 @@ def profile_identity_required(func):
try:
target = APIdentity.get_by_handle(user_name, match_linked=True)
except APIdentity.DoesNotExist:
except ObjectDoesNotExist:
raise Http404(_("User not found"))
target_user = target.user
viewer = None

View file

@ -102,4 +102,11 @@ def disconnect_identity(request, account):
_("You cannot disconnect last login identity."),
)
account.delete()
messages.add_message(
request,
messages.INFO,
_("Login information about {handle} has been removed.").format(
handle=account.handle
),
)
return redirect(reverse("users:info"))