Project

General

Profile

Defect #44360 ยป twofa_lost_password.patch

Vincent Robert, 2026-08-20 11:38

View differences:

app/controllers/account_controller.rb
25 25

  
26 26
  # prevents login action to be filtered by check_if_login_required application scope filter
27 27
  skip_before_action :check_if_login_required, :check_password_change
28
  skip_before_action :check_twofa_activation, :only => :logout
28
  skip_before_action :check_twofa_activation, :only => [:logout, :lost_password]
29 29

  
30 30
  # Login request and validation
31 31
  def login
test/integration/twofa_test.rb
88 88
    end
89 89
  end
90 90

  
91
  test 'should allow lost password even if twofa setup is required' do
92
    with_settings twofa: '2' do
93
      log_user('jsmith', 'jsmith')
94
      follow_redirect!
95
      assert_redirected_to '/my/twofa/totp/activate/confirm'
96

  
97
      get '/account/lost_password'
98
      assert_response :success
99
      assert_select 'input[name=mail]'
100

  
101
      post('/account/lost_password', :params => {:mail => 'jSmith@somenet.foo'})
102
      assert_redirected_to '/login'
103

  
104
      token = Token.find_by(:action => 'recovery', :user_id => User.find_by_login('jsmith').id)
105
      get('/account/lost_password', :params => {:token => token.value})
106
      assert_redirected_to '/account/lost_password'
107
      follow_redirect!
108
      assert_response :success
109

  
110
      post(
111
        '/account/lost_password',
112
        :params => {
113
          :token => token.value, :new_password => 'newpass123',
114
          :new_password_confirmation => 'newpass123'
115
        }
116
      )
117
      assert_redirected_to '/login'
118
      assert_equal 'Password was successfully updated.', flash[:notice]
119
    end
120
  end
121

  
91 122
  test 'should allow logout even if twofa setup is required' do
92 123
    with_settings twofa: '2' do
93 124
      log_user('jsmith', 'jsmith')
    (1-1/1)