feat: Handle missing registration token gracefully
Replaces the use of get_object_or_404 with a try-except block to specifically catch UserRegistration.DoesNotExist. Returns a 403 Forbidden response with a dedicated registration forbidden template for invalid tokens. Improves user experience by providing a clearer error message when the registration token is missing or invalid.
This commit is contained in:
parent
b34379b34e
commit
45425e650a
1 changed files with 4 additions and 1 deletions
|
@ -78,7 +78,10 @@ class EmailInputView(FormView):
|
||||||
|
|
||||||
class VerifyEmailView(View):
|
class VerifyEmailView(View):
|
||||||
def get(self, request, token):
|
def get(self, request, token):
|
||||||
registration = get_object_or_404(UserRegistration, token=token)
|
try:
|
||||||
|
registration = UserRegistration.objects.get(token=token)
|
||||||
|
except UserRegistration.DoesNotExist:
|
||||||
|
return render(request, "registration/registration_forbidden.html", status=403)
|
||||||
|
|
||||||
if registration.status != UserRegistration.STATUS_STARTED:
|
if registration.status != UserRegistration.STATUS_STARTED:
|
||||||
return render(request, "registration/registration_forbidden.html", status=403)
|
return render(request, "registration/registration_forbidden.html", status=403)
|
||||||
|
|
Loading…
Reference in a new issue