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
Boxiang Sun
gitlab-ce
Commits
57afaf9d
Commit
57afaf9d
authored
Apr 08, 2015
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upon successful login, clear `reset_password_token` field
Closes #1942
parent
e86e1013
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
11 deletions
+40
-11
app/controllers/sessions_controller.rb
app/controllers/sessions_controller.rb
+7
-1
spec/features/users_spec.rb
spec/features/users_spec.rb
+33
-10
No files found.
app/controllers/sessions_controller.rb
View file @
57afaf9d
...
...
@@ -26,6 +26,12 @@ class SessionsController < Devise::SessionsController
end
def
create
super
super
do
|
resource
|
# User has successfully signed in, so clear any unused reset tokens
if
resource
.
reset_password_token
.
present?
resource
.
update_attributes
(
reset_password_token:
nil
,
reset_password_sent_at:
nil
)
end
end
end
end
spec/features/users_spec.rb
View file @
57afaf9d
require
'spec_helper'
describe
'Users'
,
feature:
true
do
describe
"GET /users/sign_in"
do
it
"should create a new user account"
do
feature
'Users'
do
around
do
|
ex
|
old_url_options
=
Rails
.
application
.
routes
.
default_url_options
Rails
.
application
.
routes
.
default_url_options
=
{
host:
'example.foo'
}
ex
.
run
Rails
.
application
.
routes
.
default_url_options
=
old_url_options
end
scenario
'GET /users/sign_in creates a new user account'
do
visit
new_user_session_path
fill_in
"user_name"
,
with:
"Name Surname"
fill_in
"user_username"
,
with:
"Great"
fill_in
"user_email"
,
with:
"name@mail.com"
fill_in
"user_password_sign_up"
,
with:
"password1234"
expect
{
click_button
"Sign up"
}.
to
change
{
User
.
count
}.
by
(
1
)
fill_in
'user_name'
,
with:
'Name Surname'
fill_in
'user_username'
,
with:
'Great'
fill_in
'user_email'
,
with:
'name@mail.com'
fill_in
'user_password_sign_up'
,
with:
'password1234'
expect
{
click_button
'Sign up'
}.
to
change
{
User
.
count
}.
by
(
1
)
end
scenario
'Successful user signin invalidates password reset token'
do
user
=
create
(
:user
)
expect
(
user
.
reset_password_token
).
to
be_nil
visit
new_user_password_path
fill_in
'user_email'
,
with:
user
.
email
click_button
'Reset password'
user
.
reload
expect
(
user
.
reset_password_token
).
not_to
be_nil
login_with
(
user
)
expect
(
current_path
).
to
eq
root_path
user
.
reload
expect
(
user
.
reset_password_token
).
to
be_nil
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