diff --git a/rhodecode/apps/login/views.py b/rhodecode/apps/login/views.py --- a/rhodecode/apps/login/views.py +++ b/rhodecode/apps/login/views.py @@ -34,7 +34,7 @@ from pyramid.renderers import render from pyramid.response import Response from pyramid.httpexceptions import HTTPFound - +import rhodecode from rhodecode.apps._base import BaseAppView from rhodecode.authentication.base import authenticate, HTTP_TYPE from rhodecode.authentication.plugins import auth_rhodecode @@ -510,9 +510,10 @@ class LoginView(BaseAppView): # only then we should persist it secret = user_instance.init_secret_2fa(persist=False) - totp_name = f'RhodeCode token ({self.request.user.username})' + instance_name = rhodecode.ConfigGet().get_str('app.base_url', 'rhodecode') + totp_name = f'{instance_name}:{self.request.user.username}' - qr = qrcode.QRCode(version=1, box_size=10, border=5) + qr = qrcode.QRCode(version=1, box_size=5, border=4) qr.add_data(pyotp.totp.TOTP(secret).provisioning_uri(name=totp_name)) qr.make(fit=True) img = qr.make_image(fill_color='black', back_color='white') diff --git a/rhodecode/model/db.py b/rhodecode/model/db.py --- a/rhodecode/model/db.py +++ b/rhodecode/model/db.py @@ -919,7 +919,7 @@ class User(Base, BaseModel): return '' def get_secret_2fa(self) -> str: - secret_2fa = self.user_data['secret_2fa'] + secret_2fa = self.user_data.get('secret_2fa') if secret_2fa: strict_mode = ConfigGet().get_bool('rhodecode.encrypted_values.strict', missing=True) return safe_str( diff --git a/rhodecode/templates/configure_2fa.mako b/rhodecode/templates/configure_2fa.mako --- a/rhodecode/templates/configure_2fa.mako +++ b/rhodecode/templates/configure_2fa.mako @@ -6,9 +6,11 @@ · ${h.branding(c.rhodecode_name)} %endif %def> + -
Authenticator apps like Google Authenticator, etc. generate one-time passwords that are used as a second factor to verify you identity.
${_('Account')}: ${totp_name}
${_('Use an authenticator app to scan.')}
-