kumidc/authentication/views/reverify.py

29 lines
926 B
Python
Raw Normal View History

2022-08-04 11:15:10 +00:00
from django.contrib.auth.views import LoginView
from django.utils import timezone
from django.http import HttpResponseRedirect
from django.urls import reverse_lazy
from ..forms.otp import TOTPLoginForm
2023-07-08 14:11:38 +00:00
from ..models.app import AppSession
2022-08-04 11:15:10 +00:00
from frontend.mixins.views import TitleMixin
class ReverifyView(TitleMixin, LoginView):
template_name = "auth/reverify.html"
form_class = TOTPLoginForm
title = "Reverify"
def dispatch(self, request, *args, **kwargs):
return super().dispatch(request, *args, **kwargs)
def form_valid(self, form):
self.request.session["LastActivity"] = timezone.now().timestamp()
2023-07-08 14:11:38 +00:00
try:
app_session = AppSession.objects.get(id=self.request.session["AppSession"])
app_session.used = True
app_session.save()
except AppSession.DoesNotExist:
pass
2022-08-04 11:15:10 +00:00
return HttpResponseRedirect(self.get_success_url())