Commit f4e937f683a294d4a2fcae8ceeedc683be1708ea
1 parent
2d2f7861
Exists in
master
and in
28 other branches
change-password: fix crash on change_password using 'error_message_for' instead of 'rescue'
AI3012
Showing
2 changed files
with
18 additions
and
20 deletions
Show diff stats
app/controllers/public/account_controller.rb
| ... | ... | @@ -127,17 +127,13 @@ class AccountController < ApplicationController |
| 127 | 127 | if request.post? |
| 128 | 128 | @user = current_user |
| 129 | 129 | begin |
| 130 | - @user.change_password!(params[:current_password], | |
| 131 | - params[:new_password], | |
| 132 | - params[:new_password_confirmation]) | |
| 133 | - session[:notice] = _('Your password has been changed successfully!') | |
| 134 | - redirect_to :action => 'index' | |
| 135 | - rescue User::IncorrectPassword => e | |
| 136 | - session[:notice] = _('The supplied current password is incorrect.') | |
| 137 | - render :action => 'change_password' | |
| 130 | + @user.change_password!(params[:current_password], | |
| 131 | + params[:new_password], | |
| 132 | + params[:new_password_confirmation]) | |
| 133 | + session[:notice] = _('Your password has been changed successfully!') | |
| 134 | + redirect_to :action => 'index' | |
| 135 | + rescue | |
| 138 | 136 | end |
| 139 | - else | |
| 140 | - render :action => 'change_password' | |
| 141 | 137 | end |
| 142 | 138 | end |
| 143 | 139 | ... | ... |
app/views/account/change_password.rhtml
| 1 | 1 | <h1><%= _('Change password') %></h1> |
| 2 | 2 | |
| 3 | -<%= error_messages_for :change_password %> | |
| 3 | +<%= error_messages_for :user %> | |
| 4 | 4 | |
| 5 | -<% form_for(:change_password) do |f| %> | |
| 5 | +<% form_tag do %> | |
| 6 | 6 | |
| 7 | - <%= labelled_form_field(_('Current password'), (f.password_field :current_password)) %> | |
| 8 | - <%= labelled_form_field(_('New password'), (f.password_field :new_password)) %> | |
| 9 | - <%= labelled_form_field(_('Confirm your new Password'), (f.password_field :new_password_confirmation)) %> | |
| 7 | +<p><label for="password"><%= _('Current password') %></label><br/> | |
| 8 | +<%= password_field_tag :current_password %></p> | |
| 10 | 9 | |
| 11 | - <p> | |
| 12 | - <% button_bar do %> | |
| 13 | - <%= submit_button :ok, _('Change password') %> | |
| 14 | - <% end %> | |
| 15 | - </p> | |
| 10 | +<p><label for="password"><%= _('New password') %></label><br/> | |
| 11 | +<%= password_field_tag :new_password %></p> | |
| 12 | + | |
| 13 | +<p><label for="password_confirmation"><%= _('Confirm your new Password') %></label><br/> | |
| 14 | +<%= password_field_tag :new_password_confirmation %></p> | |
| 15 | + | |
| 16 | +<%= submit_button :ok, _('Change password') %> | |
| 16 | 17 | |
| 17 | 18 | <% end %> |
| 19 | + | ... | ... |