Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions app/controllers/users/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,9 @@ def increment_session_bad_password_count
end

def process_locked_out_session
irs_attempts_api_tracker.login_rate_limited(
email: auth_params[:email],
)

irs_attempts_api_tracker.login_rate_limited(email: auth_params[:email])
warden.logout(:user)
warden.lock!
flash[:error] = t('errors.sign_in.bad_password_limit')
redirect_to root_url
end
Expand Down
14 changes: 10 additions & 4 deletions spec/features/visitors/bad_password_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

RSpec.feature 'Visitor signs in with bad passwords and gets locked out',
allowed_extra_analytics: [:*] do
let(:bad_email) { 'bad@email.com' }
let(:user) { create(:user, :fully_registered) }
let(:bad_password) { 'badpassword' }

scenario 'visitor tries too many bad passwords gets locked out then waits window seconds' do
Expand All @@ -12,17 +12,23 @@
link_html: t('devise.failure.invalid_link_text'),
)
IdentityConfig.store.max_bad_passwords.times do
fill_in_credentials_and_submit(bad_email, bad_password)
fill_in_credentials_and_submit(user.email, bad_password)
expect(page).to have_content(error_message)
expect(page).to have_current_path(new_user_session_path)
end
2.times do
fill_in_credentials_and_submit(bad_email, bad_password)
fill_in_credentials_and_submit(user.email, bad_password)
expect(page).to have_current_path(new_user_session_path)
expect(page).to have_content(t('errors.sign_in.bad_password_limit'))
end
fill_in_credentials_and_submit(user.email, user.password)
expect(page).to have_current_path(new_user_session_path)
expect(page).to have_content(t('errors.sign_in.bad_password_limit'))
travel_to(IdentityConfig.store.max_bad_passwords_window_in_seconds.seconds.from_now) do
fill_in_credentials_and_submit(bad_email, bad_password)
fill_in_credentials_and_submit(user.email, bad_password)
expect(page).to have_content(error_message)
fill_in_credentials_and_submit(user.email, user.password)
expect(page).to have_current_path(login_two_factor_path(otp_delivery_preference: 'sms'))
end
end
end