diff --git a/tildes/tildes/templates/settings_two_factor.jinja2 b/tildes/tildes/templates/settings_two_factor.jinja2 index c947a21..60c993a 100644 --- a/tildes/tildes/templates/settings_two_factor.jinja2 +++ b/tildes/tildes/templates/settings_two_factor.jinja2 @@ -29,12 +29,9 @@

Next, scan the below QR code with the app of your choice.

-{% set chunk_size = 4 %} -

-{% for i in range (0, two_factor_secret|length, chunk_size) %} -{{ two_factor_secret[i:i+chunk_size] }} -{% endfor %} -

+ +

If you are unable to scan the QR code, you can enter the following key: +

{{ two_factor_secret }}

Lastly, enter the 6-digit code displayed in the app.

diff --git a/tildes/tildes/views/settings.py b/tildes/tildes/views/settings.py index 2932a6c..e12c906 100644 --- a/tildes/tildes/views/settings.py +++ b/tildes/tildes/views/settings.py @@ -10,6 +10,7 @@ from pyramid.view import view_config import qrcode from webargs.pyramidparser import use_kwargs +from tildes.lib.string import separate_string from tildes.schemas.user import EMAIL_ADDRESS_NOTE_MAX_LENGTH, UserSchema @@ -56,7 +57,9 @@ def get_settings_two_factor(request: Request) -> dict: if request.user.two_factor_secret is None: request.user.two_factor_secret = pyotp.random_base32() - return {"two_factor_secret": request.user.two_factor_secret} + return { + "two_factor_secret": separate_string(request.user.two_factor_secret, " ", 4) + } @view_config(