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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
8e51c481
Commit
8e51c481
authored
May 14, 2018
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Does not log failed sign-in attempts when database is in read-only mode
parent
efd7b57b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
0 deletions
+17
-0
app/models/user.rb
app/models/user.rb
+3
-0
spec/models/user_spec.rb
spec/models/user_spec.rb
+14
-0
No files found.
app/models/user.rb
View file @
8e51c481
...
...
@@ -1097,8 +1097,11 @@ class User < ActiveRecord::Base
# <https://github.com/plataformatec/devise/blob/v4.0.0/lib/devise/models/lockable.rb#L92>
#
def
increment_failed_attempts!
return
if
::
Gitlab
::
Database
.
read_only?
self
.
failed_attempts
||=
0
self
.
failed_attempts
+=
1
if
attempts_exceeded?
lock_access!
unless
access_locked?
else
...
...
spec/models/user_spec.rb
View file @
8e51c481
...
...
@@ -2755,4 +2755,18 @@ describe User do
it
{
is_expected
.
to
be_truthy
}
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