Defect #37456

undefined local variable or method `twofa_scheme' after a redmine upgrade

Added by dm_red mine 3 months ago. Updated 2 months ago.

Status:Needs feedbackStart date:
Priority:NormalDue date:
Assignee:-% Done:


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


After a migration from Bitnami Redmine 3.0.1.stable on Windows Server 2008 to Bitnami Redmine 5.0.0 Debian OVA the following error shows up every time a user tries to login:

I, [2022-07-18T11:01:03.246954 #8025]  INFO -- : [6f4db560-f176-4a6c-9010-f7bef4b6f7ca] Started GET "/" for at 2022-07-18 11:01:03 +0200
I, [2022-07-18T11:01:03.249250 #8025]  INFO -- : [6f4db560-f176-4a6c-9010-f7bef4b6f7ca] Processing by WelcomeController#index as HTML
I, [2022-07-18T11:01:03.256008 #8025]  INFO -- : [6f4db560-f176-4a6c-9010-f7bef4b6f7ca]   Current user: anonymous
I, [2022-07-18T11:01:03.257374 #8025]  INFO -- : [6f4db560-f176-4a6c-9010-f7bef4b6f7ca] Redirected to
I, [2022-07-18T11:01:03.257590 #8025]  INFO -- : [6f4db560-f176-4a6c-9010-f7bef4b6f7ca] Filter chain halted as :check_if_login_required rendered or redirected
I, [2022-07-18T11:01:03.257947 #8025]  INFO -- : [6f4db560-f176-4a6c-9010-f7bef4b6f7ca] Completed 302 Found in 8ms (ActiveRecord: 1.2ms | Allocations: 752)
I, [2022-07-18T11:01:03.280854 #8025]  INFO -- : [49f13a86-d622-4b90-acd2-b824cf1e7a72] Started GET "/login?back_url=http%3A%2F%2F192.168.239.153%2F" for at 2022-07-18 11:01:03 +0200
I, [2022-07-18T11:01:03.282560 #8025]  INFO -- : [49f13a86-d622-4b90-acd2-b824cf1e7a72] Processing by AccountController#login as HTML
I, [2022-07-18T11:01:03.282683 #8025]  INFO -- : [49f13a86-d622-4b90-acd2-b824cf1e7a72]   Parameters: {"back_url"=>""}
I, [2022-07-18T11:01:03.287458 #8025]  INFO -- : [49f13a86-d622-4b90-acd2-b824cf1e7a72]   Current user: anonymous
I, [2022-07-18T11:01:03.292440 #8025]  INFO -- : [49f13a86-d622-4b90-acd2-b824cf1e7a72]   Rendered account/login.html.erb within layouts/base (Duration: 2.7ms | Allocations: 330)
I, [2022-07-18T11:01:03.301678 #8025]  INFO -- : [49f13a86-d622-4b90-acd2-b824cf1e7a72]   Rendered layout layouts/base.html.erb (Duration: 12.0ms | Allocations: 1656)
I, [2022-07-18T11:01:03.302336 #8025]  INFO -- : [49f13a86-d622-4b90-acd2-b824cf1e7a72] Completed 200 OK in 19ms (Views: 13.4ms | ActiveRecord: 0.5ms | Allocations: 2551)
I, [2022-07-18T11:01:16.137931 #8025]  INFO -- : [1be66728-17aa-456e-93bf-0635666ef6b3] Started POST "/login" for at 2022-07-18 11:01:16 +0200
I, [2022-07-18T11:01:16.140338 #8025]  INFO -- : [1be66728-17aa-456e-93bf-0635666ef6b3] Processing by AccountController#login as HTML
I, [2022-07-18T11:01:16.140511 #8025]  INFO -- : [1be66728-17aa-456e-93bf-0635666ef6b3]   Parameters: {"utf8"=>"✓", "authenticity_token"=>"x0fmpZLHZaF7g3sihR1E/7RgJNdMO2x4SxL/gu24snlnKi+rI3qARS7kJTD/a2kKGYIkRTmms9uCX5rNcyX31A==", "back_url"=>"/", "username"=>"redadmin", "password"=>"[FILTERED]", "login"=>"Login"}
I, [2022-07-18T11:01:16.147781 #8025]  INFO -- : [1be66728-17aa-456e-93bf-0635666ef6b3]   Current user: anonymous
I, [2022-07-18T11:01:16.276229 #8025]  INFO -- : [1be66728-17aa-456e-93bf-0635666ef6b3] Completed 500 Internal Server Error in 135ms (ActiveRecord: 5.5ms | Allocations: 6161)
F, [2022-07-18T11:01:16.278634 #8025] FATAL -- : [1be66728-17aa-456e-93bf-0635666ef6b3]   
[1be66728-17aa-456e-93bf-0635666ef6b3] NameError (undefined local variable or method `twofa_scheme' for #<User id: 1, login: "redadmin", hashed_password: [FILTERED], firstname: "Administrador RedMine", lastname: "Admin", admin: true, status: 1, last_login_on: "2022-07-18 09:01:16.000000000 +0000", language: "en", auth_source_id: nil, created_on: "2012-05-02 14:54:13.000000000 +0000", updated_on: "2014-02-24 10:32:49.000000000 +0000", type: "User", identity_url: nil, mail_notification: "all", salt: "f9505b42a8bb5246025331e817604047", must_change_passwd: false, passwd_changed_on: nil>
Did you mean?  twofa_active?):
[1be66728-17aa-456e-93bf-0635666ef6b3] app/models/user.rb:383:in `twofa_active?'
[1be66728-17aa-456e-93bf-0635666ef6b3] app/controllers/account_controller.rb:309:in `password_authentication'
[1be66728-17aa-456e-93bf-0635666ef6b3] app/controllers/account_controller.rb:296:in `authenticate_user'
[1be66728-17aa-456e-93bf-0635666ef6b3] app/controllers/account_controller.rb:33:in `login'
[1be66728-17aa-456e-93bf-0635666ef6b3] lib/redmine/sudo_mode.rb:61:in `sudo_mode'

The steps I followed during the migration:

  1. Copy redmine/files from the old server to the new one and fix permissions.
  2. Backup old db and import into the new server.
  3. Run sudo rake db:migrate RAILS_ENV=production
  4. Reboot.

Since the previous install is very old and this setting probably didn't exist I am getting those errors now. Unfortunately I do not know how to fix my db to stop giving errors with twofa, if anyone knows how to do it please let me know, I am stuck.

Old environment versions:

Redmine version 3.0.1.stable
Ruby version 2.0.0-p594 (2014-10-27) [i386-mingw32]
Rails version 4.2.0
Environment production
Database adapter Mysql2
Subversion 1.8.10
Git 1.9.5
Redmine plugins:
no plugin installed

New environment:
Redmine version 5.0.0 stable
Ruby version 3.0.4p208 (2022-04-12 revision 3fa771dded) [x86_64-linux]



#1 Updated by dm_red mine 3 months ago

  • Status changed from New to Resolved

#2 Updated by Holger Just 2 months ago

  • Status changed from Resolved to Needs feedback

twofa_scheme is a column on the users table (and thus a method on the User class). The column was introduced some time after the release of 3.0.1. If you get this error in your updated Redmine, it thus means that you have not (fully) run all migrations to update your database to your new version of Redmine.

Make sure you have configured the correct database for the production environment in your config/database.yml and run bundle exec rake db:migrate RAILS_ENV=production again. Also make sure that your application server which is actually running the application is also configured to use the production environment. It may be that it uses some other environment which you may have configured with some other (older) database.

Also available in: Atom PDF