Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '14552-signup-password-leak' into 'master'
Don't populate the password field on signup validation errors - Previously, we were pulling `params[:user][:password]` as the default value for the password field. This is incorrect; we should be pulling it from `@user.password` or the like. [Closes #14552] See merge request !3691
- Loading branch information
Showing
3 changed files
with
60 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
require 'spec_helper' | ||
|
||
feature 'Signup', feature: true do | ||
describe 'signup with no errors' do | ||
it 'creates the user account and sends a confirmation email' do | ||
user = build(:user) | ||
|
||
visit root_path | ||
|
||
fill_in 'user_name', with: user.name | ||
fill_in 'user_username', with: user.username | ||
fill_in 'user_email', with: user.email | ||
fill_in 'user_password_sign_up', with: user.password | ||
click_button "Sign up" | ||
|
||
expect(current_path).to eq user_session_path | ||
expect(page).to have_content("A message with a confirmation link has been sent to your email address.") | ||
end | ||
end | ||
|
||
describe 'signup with errors' do | ||
it "displays the errors" do | ||
existing_user = create(:user) | ||
user = build(:user) | ||
|
||
visit root_path | ||
|
||
fill_in 'user_name', with: user.name | ||
fill_in 'user_username', with: user.username | ||
fill_in 'user_email', with: existing_user.email | ||
fill_in 'user_password_sign_up', with: user.password | ||
click_button "Sign up" | ||
|
||
expect(current_path).to eq user_registration_path | ||
expect(page).to have_content("error prohibited this user from being saved") | ||
expect(page).to have_content("Email has already been taken") | ||
end | ||
|
||
it 'does not redisplay the password' do | ||
existing_user = create(:user) | ||
user = build(:user) | ||
|
||
visit root_path | ||
|
||
fill_in 'user_name', with: user.name | ||
fill_in 'user_username', with: user.username | ||
fill_in 'user_email', with: existing_user.email | ||
fill_in 'user_password_sign_up', with: user.password | ||
click_button "Sign up" | ||
|
||
expect(current_path).to eq user_registration_path | ||
expect(page.body).not_to match(/#{user.password}/) | ||
end | ||
end | ||
end |