mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 19:41:11 +00:00
lint
This commit is contained in:
parent
8837495ffd
commit
1d13f0ab4f
3 changed files with 23 additions and 5 deletions
|
@ -32,7 +32,13 @@ from .preferences.edit_user import EditUser
|
|||
from .preferences.export import Export
|
||||
from .preferences.delete_user import DeleteUser
|
||||
from .preferences.block import Block, unblock
|
||||
from .preferences.two_factor_auth import Edit2FA, Confirm2FA, Disable2FA, LoginWith2FA, Prompt2FA
|
||||
from .preferences.two_factor_auth import (
|
||||
Edit2FA,
|
||||
Confirm2FA,
|
||||
Disable2FA,
|
||||
LoginWith2FA,
|
||||
Prompt2FA,
|
||||
)
|
||||
|
||||
# books
|
||||
from .books.books import (
|
||||
|
|
|
@ -54,7 +54,11 @@ class Login(View):
|
|||
# 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})
|
||||
return TemplateResponse(
|
||||
request,
|
||||
"two_factor_auth/two_factor_login.html",
|
||||
{"form": form, "2fa_user": user},
|
||||
)
|
||||
|
||||
# otherwise, successful login
|
||||
login(request, user)
|
||||
|
@ -84,6 +88,7 @@ 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"""
|
||||
|
|
|
@ -96,18 +96,25 @@ class LoginWith2FA(View):
|
|||
|
||||
def post(self, request):
|
||||
"""Check 2FA code and allow/disallow login"""
|
||||
user = models.User.objects.get(username=request.POST.get('2fa_user'))
|
||||
user = models.User.objects.get(username=request.POST.get("2fa_user"))
|
||||
form = forms.Confirm2FAForm(request.POST, instance=user)
|
||||
if not form.is_valid():
|
||||
time.sleep(2) # make life slightly harder for bots
|
||||
data = {"form": form, "2fa_user": user, "error": "Code does not match, try again"}
|
||||
return TemplateResponse(request, "two_factor_auth/two_factor_login.html", data)
|
||||
data = {
|
||||
"form": form,
|
||||
"2fa_user": user,
|
||||
"error": "Code does not match, try again",
|
||||
}
|
||||
return TemplateResponse(
|
||||
request, "two_factor_auth/two_factor_login.html", data
|
||||
)
|
||||
|
||||
# log the user in - we are bypassing standard login
|
||||
login(request, user)
|
||||
user.update_active_date()
|
||||
return set_language(user, redirect("/"))
|
||||
|
||||
|
||||
class Prompt2FA(View):
|
||||
"""Alert user to the existence of 2FA"""
|
||||
|
||||
|
|
Loading…
Reference in a new issue