# HG changeset patch # User RhodeCode Admin # Date 2024-04-24 07:49:39 # Node ID 4bc46af9518887cb5dcafce7d2e19e85ce682e1e # Parent a11e6ff3aee8d300efa6b8844ce7b105ac639814 feat(2fa): updates routes names and urls to better reflect actions 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 @@ -500,7 +500,7 @@ class LoginView(BaseAppView): user_instance.set_2fa_secret(secret) Session().commit() - raise HTTPFound(self.request.route_path('my_account_enable_2fa', _query={'show-recovery-codes': 1})) + raise HTTPFound(self.request.route_path('my_account_configure_2fa', _query={'show-recovery-codes': 1})) except formencode.Invalid as errors: defaults = errors.value render_ctx = { diff --git a/rhodecode/apps/my_account/__init__.py b/rhodecode/apps/my_account/__init__.py --- a/rhodecode/apps/my_account/__init__.py +++ b/rhodecode/apps/my_account/__init__.py @@ -76,21 +76,21 @@ def includeme(config): # my account 2fa config.add_route( - name='my_account_enable_2fa', - pattern=ADMIN_PREFIX + '/my_account/enable_2fa') + name='my_account_configure_2fa', + pattern=ADMIN_PREFIX + '/my_account/configure_2fa') config.add_view( MyAccountView, attr='my_account_2fa', - route_name='my_account_enable_2fa', request_method='GET', + route_name='my_account_configure_2fa', request_method='GET', renderer='rhodecode:templates/admin/my_account/my_account.mako') # my account 2fa save config.add_route( - name='my_account_enable_2fa_save', - pattern=ADMIN_PREFIX + '/my_account/enable_2fa_save') + name='my_account_configure_2fa_update', + pattern=ADMIN_PREFIX + '/my_account/configure_2fa_update') config.add_view( MyAccountView, attr='my_account_2fa_update', - route_name='my_account_enable_2fa_save', request_method='POST', + route_name='my_account_configure_2fa_update', request_method='POST', renderer='rhodecode:templates/admin/my_account/my_account.mako') # my account 2fa recovery code-reset diff --git a/rhodecode/apps/my_account/views/my_account.py b/rhodecode/apps/my_account/views/my_account.py --- a/rhodecode/apps/my_account/views/my_account.py +++ b/rhodecode/apps/my_account/views/my_account.py @@ -231,7 +231,7 @@ class MyAccountView(BaseAppView, DataGri user_instance.update_userdata(update_2fa=time.time()) Session().commit() h.flash(_("Successfully saved 2FA settings"), category='success') - raise HTTPFound(self.request.route_path('my_account_enable_2fa')) + raise HTTPFound(self.request.route_path('my_account_configure_2fa')) @LoginRequired() @NotAnonymous() @@ -262,12 +262,12 @@ class MyAccountView(BaseAppView, DataGri Session().commit() except formencode.Invalid as errors: h.flash(_("Failed to generate new recovery codes: {}").format(errors), category='error') - raise HTTPFound(self.request.route_path('my_account_enable_2fa')) + raise HTTPFound(self.request.route_path('my_account_configure_2fa')) except Exception as e: h.flash(_("Failed to generate new recovery codes: {}").format(e), category='error') - raise HTTPFound(self.request.route_path('my_account_enable_2fa')) + raise HTTPFound(self.request.route_path('my_account_configure_2fa')) - raise HTTPFound(self.request.route_path('my_account_enable_2fa', _query={'show-recovery-codes': 1})) + raise HTTPFound(self.request.route_path('my_account_configure_2fa', _query={'show-recovery-codes': 1})) @LoginRequired() @NotAnonymous() diff --git a/rhodecode/public/js/rhodecode/routes.js b/rhodecode/public/js/rhodecode/routes.js --- a/rhodecode/public/js/rhodecode/routes.js +++ b/rhodecode/public/js/rhodecode/routes.js @@ -215,12 +215,12 @@ function registerRCRoutes() { pyroutes.register('my_account_auth_tokens_view', '/_admin/my_account/auth_tokens/view', []); pyroutes.register('my_account_bookmarks', '/_admin/my_account/bookmarks', []); pyroutes.register('my_account_bookmarks_update', '/_admin/my_account/bookmarks/update', []); + pyroutes.register('my_account_configure_2fa', '/_admin/my_account/configure_2fa', []); + pyroutes.register('my_account_configure_2fa_update', '/_admin/my_account/configure_2fa_update', []); pyroutes.register('my_account_edit', '/_admin/my_account/edit', []); pyroutes.register('my_account_emails', '/_admin/my_account/emails', []); pyroutes.register('my_account_emails_add', '/_admin/my_account/emails/new', []); pyroutes.register('my_account_emails_delete', '/_admin/my_account/emails/delete', []); - pyroutes.register('my_account_enable_2fa', '/_admin/my_account/enable_2fa', []); - pyroutes.register('my_account_enable_2fa_save', '/_admin/my_account/enable_2fa_save', []); pyroutes.register('my_account_external_identity', '/_admin/my_account/external-identity', []); pyroutes.register('my_account_external_identity_delete', '/_admin/my_account/external-identity/delete', []); pyroutes.register('my_account_goto_bookmark', '/_admin/my_account/bookmark/%(bookmark_id)s', ['bookmark_id']); diff --git a/rhodecode/templates/admin/my_account/my_account.mako b/rhodecode/templates/admin/my_account/my_account.mako --- a/rhodecode/templates/admin/my_account/my_account.mako +++ b/rhodecode/templates/admin/my_account/my_account.mako @@ -28,7 +28,7 @@
  • ${_('Profile')}
  • ${_('Emails')}
  • ${_('Password')}
  • -
  • ${_('2FA')}
  • +
  • ${_('2FA')}
  • ${_('Bookmarks')}
  • ${_('Auth Tokens')}
  • ${_('SSH Keys')}
  • diff --git a/rhodecode/templates/admin/my_account/my_account_2fa.mako b/rhodecode/templates/admin/my_account/my_account_2fa.mako --- a/rhodecode/templates/admin/my_account/my_account_2fa.mako +++ b/rhodecode/templates/admin/my_account/my_account_2fa.mako @@ -4,7 +4,7 @@

    ${_('Enable/Disable 2FA for your account')}

    - ${h.secure_form(h.route_path('my_account_enable_2fa_save'), request=request)} + ${h.secure_form(h.route_path('my_account_configure_2fa_update'), request=request)}
    @@ -50,7 +50,7 @@ ${_('Please save them in a safe place, or you will lose access to your account in case of lost access to authenticator app.')}


    - ${_('Show recovery codes')} + ${_('Show recovery codes')}
    % endif