pull/13959/head
Alberto Romeu 6 years ago
parent 4a04b0bef1
commit 85a19d9163

@ -23,14 +23,13 @@ class PasswordChangeController < SessionsController
pwc = params[:password_confirmation]
if pw.blank? || pwc.blank? || pw != pwc
@user.errors.add(:password, PASSWORD_MATCH_MSG)
@user.errors.add(:password_confirmation, PASSWORD_MATCH_MSG)
@new_password_error = PASSWORD_MATCH_MSG
render :edit
return
end
unless @user.validate_old_password(opw)
@user.errors.add(:old_password, WRONG_PASSWORD_MSG)
@old_password_error = WRONG_PASSWORD_MSG
render :edit
return
end

@ -34,24 +34,24 @@
<div class="Sessions-field">
<%= password_field_tag :old_password, "", placeholder: "Type your current password", class: "CDB-Size-medium #{@organization.present? ? 'Sessions-input' : 'Sessions-navy-input'} bottomBorderRadius" %>
<% if @user.errors['old_password'].present? %>
<div class="Sessions-fieldError js-Sessions-fieldError" data-content="<%= @user.errors['old_password'] %>">!</div>
<% if @old_password_error %>
<div class="Sessions-fieldError js-Sessions-fieldError" data-content="<%= @old_password_error %>">!</div>
<% end %>
</div>
<div class="Sessions-field">
<%= password_field_tag :password, "", placeholder: "Type your new password", class: "CDB-Size-medium #{@organization.present? ? 'Sessions-input' : 'Sessions-navy-input'} bottomBorderRadius" %>
<% if @user.errors['password'].present? %>
<div class="Sessions-fieldError js-Sessions-fieldError" data-content="<%= @user.errors['password'] %>">!</div>
<% if @new_password_error %>
<div class="Sessions-fieldError js-Sessions-fieldError" data-content="<%= @new_password_error %>">!</div>
<% end %>
</div>
<div class="Sessions-field">
<%= password_field_tag :password_confirmation, "", placeholder: "Retype your new password", class: "CDB-Size-medium #{@organization.present? ? 'Sessions-input' : 'Sessions-navy-input'} bottomBorderRadius" %>
<% if @user.errors['password_confirmation'].present? %>
<div class="Sessions-fieldError js-Sessions-fieldError" data-content="<%= @user.errors['password_confirmation'] %>">!</div>
<% if @new_password_error %>
<div class="Sessions-fieldError js-Sessions-fieldError" data-content="<%= @new_password_error %>">!</div>
<% end %>
</div>

@ -43,8 +43,7 @@ describe PasswordChangeController do
put password_change_url(@user.username), payload_wrong_old_password, @headers
response.status.should == 200
# response.body.should include 'Please ensure you typed the password correctly'
response.body.should include 'has expired'
response.body.should include 'Please ensure you typed the password correctly'
request.path.should eq password_change_path(@user.username)
end
@ -53,8 +52,7 @@ describe PasswordChangeController do
put password_change_url(@user.username), payload_mismatch_new_password, @headers
response.status.should == 200
# response.body.should include 'Please ensure your passwords match'
response.body.should include 'has expired'
response.body.should include 'Please ensure your passwords match'
request.path.should eq password_change_path(@user.username)
end

Loading…
Cancel
Save