Commit 08b30ebf9132671923ff4bf78b002b810abcc634
Exists in
master
and in
29 other branches
Merge remote branch 'junior/change-password' into stable
Showing
3 changed files
with
18 additions
and
10 deletions
Show diff stats
app/controllers/public/account_controller.rb
... | ... | @@ -130,17 +130,13 @@ class AccountController < ApplicationController |
130 | 130 | if request.post? |
131 | 131 | @user = current_user |
132 | 132 | begin |
133 | - @user.change_password!(params[:current_password], | |
134 | - params[:new_password], | |
135 | - params[:new_password_confirmation]) | |
136 | - session[:notice] = _('Your password has been changed successfully!') | |
137 | - redirect_to :action => 'index' | |
138 | - rescue User::IncorrectPassword => e | |
139 | - session[:notice] = _('The supplied current password is incorrect.') | |
140 | - render :action => 'change_password' | |
133 | + @user.change_password!(params[:current_password], | |
134 | + params[:new_password], | |
135 | + params[:new_password_confirmation]) | |
136 | + session[:notice] = _('Your password has been changed successfully!') | |
137 | + redirect_to :action => 'index' | |
138 | + rescue | |
141 | 139 | end |
142 | - else | |
143 | - render :action => 'change_password' | |
144 | 140 | end |
145 | 141 | end |
146 | 142 | ... | ... |
app/views/account/change_password.rhtml
test/functional/account_controller_test.rb
... | ... | @@ -203,6 +203,16 @@ class AccountControllerTest < ActionController::TestCase |
203 | 203 | assert_equal users(:ze), @controller.send(:current_user) |
204 | 204 | end |
205 | 205 | |
206 | + should "not change password when new password and new password confirmation don't match" do | |
207 | + login_as 'ze' | |
208 | + post :change_password, :current_password => 'test', :new_password => 'blabla', :new_password_confirmation => 'blibli' | |
209 | + assert_response :success | |
210 | + assert_template 'change_password' | |
211 | + assert !assigns(:current_user).authenticated?('blabla') | |
212 | + assert !assigns(:current_user).authenticated?('blibli') | |
213 | + assert_equal users(:ze), @controller.send(:current_user) | |
214 | + end | |
215 | + | |
206 | 216 | should 'provide a "I forget my password" link at the login page' do |
207 | 217 | get :login |
208 | 218 | assert_tag :tag => 'a', :attributes => { | ... | ... |