mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-23 01:51:08 +00:00
make pylint stop grumbling
This commit is contained in:
parent
1d13f0ab4f
commit
9d12b7caff
3 changed files with 11 additions and 9 deletions
|
@ -4,12 +4,12 @@ from django.contrib.auth.password_validation import validate_password
|
|||
from django.core.exceptions import ValidationError
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
import pyotp
|
||||
|
||||
from bookwyrm import models
|
||||
from bookwyrm.models.fields import ClearableFileInputWithWarning
|
||||
from .custom_form import CustomForm
|
||||
|
||||
import pyotp
|
||||
|
||||
# pylint: disable=missing-class-docstring
|
||||
class EditUserForm(CustomForm):
|
||||
class Meta:
|
||||
|
|
|
@ -29,6 +29,7 @@ class Login(View):
|
|||
}
|
||||
return TemplateResponse(request, "landing/login.html", data)
|
||||
|
||||
#pylint: disable=too-many-return-statements
|
||||
@sensitive_variables("password")
|
||||
@method_decorator(sensitive_post_parameters("password"))
|
||||
def post(self, request):
|
||||
|
@ -52,7 +53,7 @@ class Login(View):
|
|||
user = authenticate(request, username=username, password=password)
|
||||
if user is not None:
|
||||
# if 2fa is set, don't log them in until they enter the right code
|
||||
if user.two_factor_auth == True:
|
||||
if user.two_factor_auth is True:
|
||||
form = forms.Confirm2FAForm(request.GET, user)
|
||||
return TemplateResponse(
|
||||
request,
|
||||
|
@ -66,7 +67,7 @@ class Login(View):
|
|||
if request.POST.get("first_login"):
|
||||
return set_language(user, redirect("get-started-profile"))
|
||||
|
||||
if user.two_factor_auth == None:
|
||||
if user.two_factor_auth is 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"])
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
""" class views for 2FA management """
|
||||
import time
|
||||
import pyotp
|
||||
import qrcode
|
||||
import qrcode.image.svg
|
||||
import time
|
||||
|
||||
from django.contrib.auth import login
|
||||
from django.contrib.auth.decorators import login_required
|
||||
|
@ -52,10 +52,10 @@ class Edit2FA(View):
|
|||
provisioning_url = pyotp.totp.TOTP(otp_secret).provisioning_uri(
|
||||
name=user.localname, issuer_name=DOMAIN
|
||||
)
|
||||
qr = qrcode.QRCode(image_factory=qrcode.image.svg.SvgPathImage)
|
||||
qr.add_data(provisioning_url)
|
||||
qr.make(fit=True)
|
||||
img = qr.make_image(attrib={"fill": "black"})
|
||||
qr_code = qrcode.QRCode(image_factory=qrcode.image.svg.SvgPathImage)
|
||||
qr_code.add_data(provisioning_url)
|
||||
qr_code.make(fit=True)
|
||||
img = qr_code.make_image(attrib={"fill": "black"})
|
||||
return img.to_string()
|
||||
|
||||
|
||||
|
@ -119,4 +119,5 @@ class Prompt2FA(View):
|
|||
"""Alert user to the existence of 2FA"""
|
||||
|
||||
def get(self, request):
|
||||
"""Alert user to the existence of 2FA"""
|
||||
return TemplateResponse(request, "two_factor_auth/two_factor_prompt.html")
|
||||
|
|
Loading…
Reference in a new issue