From 26592738242dc61474d7ab4502fe1e8f395aac46 Mon Sep 17 00:00:00 2001 From: Luca Date: Fri, 21 Apr 2023 22:03:55 +0200 Subject: [PATCH] Redirect to 'register' page and show warning if token is not found --- shiftregister/app/views.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/shiftregister/app/views.py b/shiftregister/app/views.py index e20d03f..4790981 100644 --- a/shiftregister/app/views.py +++ b/shiftregister/app/views.py @@ -72,7 +72,16 @@ def index(request): def login(request, token): - tk = get_object_or_404(LoginToken, pk=token) + try: + tk = LoginToken.objects.get(pk=token) + except LoginToken.DoesNotExist: + messages.add_message( + request, + messages.WARNING, + "Wir konnten dich nicht in unserer Datenbank finden. Beachte bitte, dass du dich neu registrieren musst, auch wenn du letztes Jahr bereits geholfen hast.", + ) + return redirect("register") + if not tk.helper.number_validated: tk.helper.number_validated = True tk.helper.save()