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
iv
gitlab-ce
Commits
ad7ad874
Commit
ad7ad874
authored
Oct 01, 2015
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add User#recently_sent_password_reset?
parent
19748dde
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
0 deletions
+24
-0
app/models/user.rb
app/models/user.rb
+4
-0
spec/models/user_spec.rb
spec/models/user_spec.rb
+20
-0
No files found.
app/models/user.rb
View file @
ad7ad874
...
@@ -327,6 +327,10 @@ class User < ActiveRecord::Base
...
@@ -327,6 +327,10 @@ class User < ActiveRecord::Base
@reset_token
@reset_token
end
end
def
recently_sent_password_reset?
reset_password_sent_at
.
present?
&&
reset_password_sent_at
>=
1
.
minute
.
ago
end
def
disable_two_factor!
def
disable_two_factor!
update_attributes
(
update_attributes
(
two_factor_enabled:
false
,
two_factor_enabled:
false
,
...
...
spec/models/user_spec.rb
View file @
ad7ad874
...
@@ -227,6 +227,26 @@ describe User do
...
@@ -227,6 +227,26 @@ describe User do
end
end
end
end
describe
'recently_sent_password_reset?'
do
it
'is false when reset_password_sent_at is nil'
do
user
=
build_stubbed
(
:user
,
reset_password_sent_at:
nil
)
expect
(
user
.
recently_sent_password_reset?
).
to
eq
false
end
it
'is false when sent more than one minute ago'
do
user
=
build_stubbed
(
:user
,
reset_password_sent_at:
5
.
minutes
.
ago
)
expect
(
user
.
recently_sent_password_reset?
).
to
eq
false
end
it
'is true when sent less than one minute ago'
do
user
=
build_stubbed
(
:user
,
reset_password_sent_at:
Time
.
now
)
expect
(
user
.
recently_sent_password_reset?
).
to
eq
true
end
end
describe
'#disable_two_factor!'
do
describe
'#disable_two_factor!'
do
it
'clears all 2FA-related fields'
do
it
'clears all 2FA-related fields'
do
user
=
create
(
:user
,
:two_factor
)
user
=
create
(
:user
,
:two_factor
)
...
...
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