diff --git a/bookwyrm/templates/preferences/2fa.html b/bookwyrm/templates/preferences/2fa.html index 29a011380..27ef026fb 100644 --- a/bookwyrm/templates/preferences/2fa.html +++ b/bookwyrm/templates/preferences/2fa.html @@ -46,6 +46,29 @@
{{ qrcode | safe }}
+
+ + + {% trans "Use setup key" %} + + + +
+
+ {% trans "Account name:" %} +
+
+ {{ user.username }} +
+ +
+ {% trans "Code:" %} +
+
+ {{ code | safe }} +
+
+
{{ form.otp }} diff --git a/bookwyrm/views/preferences/two_factor_auth.py b/bookwyrm/views/preferences/two_factor_auth.py index f3b04eb3c..192cdaff7 100644 --- a/bookwyrm/views/preferences/two_factor_auth.py +++ b/bookwyrm/views/preferences/two_factor_auth.py @@ -35,10 +35,12 @@ class Edit2FA(View): if not form.is_valid(): data = {"form": form} return TemplateResponse(request, "preferences/2fa.html", data) + data = self.create_qr_code(request.user) qr_form = forms.Confirm2FAForm() data = { "password_confirmed": True, - "qrcode": self.create_qr_code(request.user), + "qrcode": data[0], + "code": data[1], "form": qr_form, } return TemplateResponse(request, "preferences/2fa.html", data) @@ -57,7 +59,10 @@ class Edit2FA(View): qr_code.add_data(provisioning_url) qr_code.make(fit=True) img = qr_code.make_image(attrib={"fill": "black"}) - return str(img.to_string(), "utf-8") # to_string() returns a byte string + return [ + str(img.to_string(), "utf-8"), + otp_secret, + ] # to_string() returns a byte string @method_decorator(login_required, name="dispatch")