mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2025-06-05 23:38:53 +00:00
handle 2fa user exception properly
This commit is contained in:
parent
32e4f7718e
commit
3d95916b55
1 changed files with 3 additions and 2 deletions
|
@ -6,6 +6,7 @@ import qrcode.image.svg
|
||||||
|
|
||||||
from django.contrib.auth import login
|
from django.contrib.auth import login
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
|
from django.core.exceptions import ObjectDoesNotExist
|
||||||
from django.http import HttpResponseBadRequest
|
from django.http import HttpResponseBadRequest
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
from django.shortcuts import redirect
|
from django.shortcuts import redirect
|
||||||
|
@ -109,8 +110,8 @@ class LoginWith2FA(View):
|
||||||
def post(self, request):
|
def post(self, request):
|
||||||
"""Check 2FA code and allow/disallow login"""
|
"""Check 2FA code and allow/disallow login"""
|
||||||
try:
|
try:
|
||||||
user = models.User.objects.get(username=request.session["2fa_user"])
|
user = models.User.objects.get(username=request.session.get("2fa_user"))
|
||||||
except Exception:
|
except ObjectDoesNotExist:
|
||||||
request.session["2fa_auth_time"] = 0
|
request.session["2fa_auth_time"] = 0
|
||||||
return HttpResponseBadRequest("Invalid user")
|
return HttpResponseBadRequest("Invalid user")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue