Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
bd74ca32
Commit
bd74ca32
authored
May 09, 2018
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Does not log failed sign-in attempts when in a GitLab read-only instance
parent
3311bfdb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
0 deletions
+20
-0
ee/app/models/ee/user.rb
ee/app/models/ee/user.rb
+6
-0
ee/spec/models/ee/user_spec.rb
ee/spec/models/ee/user_spec.rb
+14
-0
No files found.
ee/app/models/ee/user.rb
View file @
bd74ca32
...
...
@@ -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
ee/spec/models/ee/user_spec.rb
View file @
bd74ca32
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment