Defect #33932

Can't view "My account" page when 2fa is setting to optional

Added by ChunChang Lo over 1 year ago. Updated over 1 year ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Go MAEDA% Done:

0%

Category:Accounts / authentication
Target version:-
Resolution: Affected version:

Description

error message:

Started GET "/my/account" for 59.127.53.179 at 2020-08-31 03:53:37 +0000
Processing by MyController#account as HTML
  Current user: shortie (id=3)
  Rendering my/account.html.erb within layouts/base
  Rendered my/account.html.erb within layouts/base (15.5ms)
Completed 500 Internal Server Error in 25ms (ActiveRecord: 3.5ms)

ActionView::Template::Error (uninitialized constant Redmine::Twofa::Base
Did you mean?  Base64):
    35:       <%=l 'twofa_currently_active', twofa_scheme_name: l("twofa__#{@user.twofa_scheme}__name") -%><br/>
    36:       <%= link_to l('button_disable'), { controller: 'twofa', action: 'deactivate_init', scheme: @user.twofa_scheme }, method: :post -%><br/>
    37:       <%= link_to l('twofa_generate_backup_codes'), { controller: 'twofa_backup_codes', action: 'init' }, method: :post, data: { confirm: Redmine::Twofa.for_user(User.current).backup_codes.any? ?
    38:     <% else %>
    39:       <% Redmine::Twofa.available_schemes.each do |s| %>
    40:         <%= link_to l("twofa__#{s}__label_activate"), { controller: 'twofa', action: 'activate_init', scheme: s }, method: :post -%><br/>
    41:       <% end %>

lib/redmine/twofa/totp.rb:22:in `<module:Twofa>'
lib/redmine/twofa/totp.rb:21:in `<module:Redmine>'
lib/redmine/twofa/totp.rb:20:in `<top (required)>'
lib/redmine/twofa.rb:58:in `block in scan_builtin_schemes'
lib/redmine/twofa.rb:57:in `each'
lib/redmine/twofa.rb:57:in `scan_builtin_schemes'
lib/redmine/twofa.rb:52:in `initialize_schemes'
lib/redmine/twofa.rb:45:in `schemes'
lib/redmine/twofa.rb:28:in `available_schemes'
app/views/my/account.html.erb:38:in `block in _app_views_my_account_html_erb__509002245855036881_70041001997940'
app/helpers/application_helper.rb:1404:in `labelled_form_for'
app/views/my/account.html.erb:14:in `_app_views_my_account_html_erb__509002245855036881_70041001997940'
lib/redmine/sudo_mode.rb:64:in `sudo_mode'

Related issues

Related to Redmine - Feature #1237: Add support for two-factor authentication Closed 2008-05-14

Associated revisions

Revision 19997
Added by Go MAEDA over 1 year ago

Fix an error "uninitialized constant Redmine::Twofa::Base" when accessing My account in production mode (#1237, #33932).

History

#1 Updated by Go MAEDA over 1 year ago

Could you describe your environment? (web server, app server)

#2 Updated by Go MAEDA over 1 year ago

  • Related to Feature #1237: Add support for two-factor authentication added

#3 Updated by Go MAEDA over 1 year ago

Go MAEDA wrote:

Could you describe your environment? (web server, app server)

And please paste the environment information on /admin/info page.

#4 Updated by ChunChang Lo over 1 year ago

  • Redmine Environment Info:
      Redmine version                4.1.1.devel.19994
      Ruby version                   2.5.5-p157 (2019-03-15) [x86_64-linux]
      Rails version                  5.2.4.2
      Environment                    production
      Database adapter               Mysql2
      Mailer queue                   ActiveJob::QueueAdapters::AsyncAdapter
      Mailer delivery                sendmail
    SCM:
      Subversion                     1.10.2
      Git                            2.18.4
      Filesystem                     
    Redmine plugins:
      no plugin installed
    
  • Other Info
    • OS: CentOS Linux 8.2.2004
    • Web Server: Apache + Phusion Passenger
    • DB: MariaDB

#5 Updated by Go MAEDA over 1 year ago

I found one of my Redmine instances also raises the exception if it runs in production mode.

Could you try the following workaround? Although I am not sure whether it is the right approach, it has fixed the issue on my affected environment.

Index: lib/redmine/twofa/totp.rb
===================================================================
--- lib/redmine/twofa/totp.rb    (revision 19994)
+++ lib/redmine/twofa/totp.rb    (working copy)
@@ -17,6 +17,8 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

+require_relative 'base'
+
 module Redmine
   module Twofa
     class Totp < Base

#6 Updated by ChunChang Lo over 1 year ago

yes. this workaround did fix the error. :)

I will keep this line until next pull, thanks a lot.

#7 Updated by Go MAEDA over 1 year ago

  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Affected version deleted (4.1.1)

Fixed in r19997. Thank you for reporting the issue.

Also available in: Atom PDF