From f4e937f683a294d4a2fcae8ceeedc683be1708ea Mon Sep 17 00:00:00 2001 From: Junior Silva Date: Tue, 15 Apr 2014 18:19:18 -0300 Subject: [PATCH] change-password: fix crash on change_password using 'error_message_for' instead of 'rescue' AI3012 --- app/controllers/public/account_controller.rb | 16 ++++++---------- app/views/account/change_password.rhtml | 22 ++++++++++++---------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/app/controllers/public/account_controller.rb b/app/controllers/public/account_controller.rb index ad603e1..6de641d 100644 --- a/app/controllers/public/account_controller.rb +++ b/app/controllers/public/account_controller.rb @@ -127,17 +127,13 @@ class AccountController < ApplicationController if request.post? @user = current_user begin - @user.change_password!(params[:current_password], - params[:new_password], - params[:new_password_confirmation]) - session[:notice] = _('Your password has been changed successfully!') - redirect_to :action => 'index' - rescue User::IncorrectPassword => e - session[:notice] = _('The supplied current password is incorrect.') - render :action => 'change_password' + @user.change_password!(params[:current_password], + params[:new_password], + params[:new_password_confirmation]) + session[:notice] = _('Your password has been changed successfully!') + redirect_to :action => 'index' + rescue end - else - render :action => 'change_password' end end diff --git a/app/views/account/change_password.rhtml b/app/views/account/change_password.rhtml index 5578eff..cc1fff3 100644 --- a/app/views/account/change_password.rhtml +++ b/app/views/account/change_password.rhtml @@ -1,17 +1,19 @@

<%= _('Change password') %>

-<%= error_messages_for :change_password %> +<%= error_messages_for :user %> -<% form_for(:change_password) do |f| %> +<% form_tag do %> - <%= labelled_form_field(_('Current password'), (f.password_field :current_password)) %> - <%= labelled_form_field(_('New password'), (f.password_field :new_password)) %> - <%= labelled_form_field(_('Confirm your new Password'), (f.password_field :new_password_confirmation)) %> +


+<%= password_field_tag :current_password %>

-

- <% button_bar do %> - <%= submit_button :ok, _('Change password') %> - <% end %> -

+


+<%= password_field_tag :new_password %>

+ +


+<%= password_field_tag :new_password_confirmation %>

+ +<%= submit_button :ok, _('Change password') %> <% end %> + -- libgit2 0.21.2