mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 19:41:11 +00:00
Merge pull request #2394 from jaschaurbach/show-2fa-code
show otp_secret when setting up 2fa
This commit is contained in:
commit
fdc53d6c60
2 changed files with 30 additions and 2 deletions
|
@ -46,6 +46,29 @@
|
|||
<div class="columns">
|
||||
<section class="column is-narrow">
|
||||
<figure class="m-4" id="qrcode">{{ qrcode | safe }}</figure>
|
||||
<details class="details-panel box">
|
||||
<summary>
|
||||
<span role="heading" aria-level="3" class="title is-6">
|
||||
{% trans "Use setup key" %}
|
||||
<span class="details-close icon icon-x" aria-hidden="true"></span>
|
||||
</span>
|
||||
</summary>
|
||||
<dl class="block">
|
||||
<dt class="has-text-weight-bold mr-5 is-pulled-left">
|
||||
{% trans "Account name:" %}
|
||||
</dt>
|
||||
<dd>
|
||||
<code>{{ user.username }}</code>
|
||||
</dd>
|
||||
|
||||
<dt class="has-text-weight-bold mr-5 is-pulled-left">
|
||||
{% trans "Code:" %}
|
||||
</dt>
|
||||
<dd>
|
||||
<code>{{ code | safe }}</code>
|
||||
</dd>
|
||||
</dl>
|
||||
</details>
|
||||
<div class="field">
|
||||
<label class="label" for="id_otp">{% trans "Enter the code from your app:" %}</label>
|
||||
{{ form.otp }}
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in a new issue