Commit 67d2b90d authored by Stan Hu's avatar Stan Hu

Merge branch...

Merge branch '5957-geo-secondary-can-t-log-failed-sign-in-attempts-due-to-read-only-db' into 'master'

Resolve "Geo: Secondary can't log failed sign-in attempts due to read-only DB"

Closes #5957

See merge request gitlab-org/gitlab-ee!5643
parents 19971836 b1770cd6
......@@ -5,6 +5,7 @@ module EE
# and be prepended in the `User` model
module User
extend ActiveSupport::Concern
extend ::Gitlab::Utils::Override
include AuditorUserHelper
included do
......@@ -91,5 +92,10 @@ module EE
def email_opted_in_source
email_opted_in_source_id == EMAIL_OPT_IN_SOURCE_ID_GITLAB_COM ? 'GitLab.com' : ''
end
override :increment_failed_attempts!
def increment_failed_attempts!
super if ::Gitlab::Database.read_write?
end
end
end
---
title: Does not log failed sign-in attempts when in a GitLab read-only instance
merge_request: 5643
author:
type: fixed
......@@ -137,4 +137,18 @@ describe EE::User do
end
end
end
describe '#increment_failed_attempts!' do
subject(:user) { create(:user, failed_attempts: 0) }
it 'logs failed sign-in attempts' do
expect { user.increment_failed_attempts! }.to change(user, :failed_attempts).from(0).to(1)
end
it 'does not log failed sign-in attempts when in a GitLab read-only instance' do
allow(Gitlab::Database).to receive(:read_only?) { true }
expect { user.increment_failed_attempts! }.not_to change(user, :failed_attempts)
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment