-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an option to not automatically sign in a user after changing a pa…
…ssword (#4569)
- Loading branch information
Showing
7 changed files
with
78 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -179,6 +179,39 @@ def user_sign_up | |
assert warden.authenticated?(:user) | ||
end | ||
|
||
test 'a signed in user should not be able to use the website after changing their password if config.sign_in_after_change_password is false' do | ||
swap Devise, sign_in_after_change_password: false do | ||
sign_in_as_user | ||
get edit_user_registration_path | ||
|
||
fill_in 'password', with: '1234567890' | ||
fill_in 'password confirmation', with: '1234567890' | ||
fill_in 'current password', with: '12345678' | ||
click_button 'Update' | ||
|
||
assert_contain 'Your account has been updated successfully, but since your password was changed, you need to sign in again' | ||
assert_equal new_user_session_path, @request.path | ||
refute warden.authenticated?(:user) | ||
end | ||
end | ||
|
||
test 'a signed in user should be able to use the website after changing its email with config.sign_in_after_change_password is false' do | ||
swap Devise, sign_in_after_change_password: false do | ||
sign_in_as_user | ||
get edit_user_registration_path | ||
|
||
fill_in 'email', with: '[email protected]' | ||
fill_in 'current password', with: '12345678' | ||
click_button 'Update' | ||
|
||
assert_current_url '/' | ||
assert_contain 'Your account has been updated successfully.' | ||
|
||
assert warden.authenticated?(:user) | ||
assert_equal "[email protected]", User.to_adapter.find_first.email | ||
end | ||
end | ||
|
||
test 'a signed in user should not change their current user with invalid password' do | ||
sign_in_as_user | ||
get edit_user_registration_path | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters