mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-23 01:51:08 +00:00
redirect login to 2fa check if active
This commit is contained in:
parent
2ec343c5db
commit
8837495ffd
1 changed files with 15 additions and 2 deletions
|
@ -51,11 +51,25 @@ class Login(View):
|
|||
# perform authentication
|
||||
user = authenticate(request, username=username, password=password)
|
||||
if user is not None:
|
||||
# successful login
|
||||
# if 2fa is set, don't log them in until they enter the right code
|
||||
if user.two_factor_auth == True:
|
||||
form = forms.Confirm2FAForm(request.GET, user)
|
||||
return TemplateResponse(request, "two_factor_auth/two_factor_login.html", {"form": form, "2fa_user": user})
|
||||
|
||||
# otherwise, successful login
|
||||
login(request, user)
|
||||
user.update_active_date()
|
||||
if request.POST.get("first_login"):
|
||||
return set_language(user, redirect("get-started-profile"))
|
||||
|
||||
if user.two_factor_auth == None:
|
||||
# set to false so this page doesn't pop up again
|
||||
user.two_factor_auth = False
|
||||
user.save(broadcast=False, update_fields=["two_factor_auth"])
|
||||
|
||||
# show the 2fa prompt page
|
||||
return set_language(user, redirect("prompt-2fa"))
|
||||
|
||||
return set_language(user, redirect("/"))
|
||||
|
||||
# maybe the user is pending email confirmation
|
||||
|
@ -70,7 +84,6 @@ class Login(View):
|
|||
data = {"login_form": login_form, "register_form": register_form}
|
||||
return TemplateResponse(request, "landing/login.html", data)
|
||||
|
||||
|
||||
@method_decorator(login_required, name="dispatch")
|
||||
class Logout(View):
|
||||
"""log out"""
|
||||
|
|
Loading…
Reference in a new issue