Commit 08b30ebf9132671923ff4bf78b002b810abcc634
Exists in
master
and in
28 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,17 +130,13 @@ class AccountController < ApplicationController | ||
130 | if request.post? | 130 | if request.post? |
131 | @user = current_user | 131 | @user = current_user |
132 | begin | 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 | end | 139 | end |
142 | - else | ||
143 | - render :action => 'change_password' | ||
144 | end | 140 | end |
145 | end | 141 | end |
146 | 142 |
app/views/account/change_password.rhtml
1 | <h1><%= _('Change password') %></h1> | 1 | <h1><%= _('Change password') %></h1> |
2 | 2 | ||
3 | +<%= error_messages_for :user %> | ||
4 | + | ||
3 | <% form_tag do %> | 5 | <% form_tag do %> |
4 | 6 | ||
5 | <p><label for="password"><%= _('Current password') %></label><br/> | 7 | <p><label for="password"><%= _('Current password') %></label><br/> |
test/functional/account_controller_test.rb
@@ -203,6 +203,16 @@ class AccountControllerTest < ActionController::TestCase | @@ -203,6 +203,16 @@ class AccountControllerTest < ActionController::TestCase | ||
203 | assert_equal users(:ze), @controller.send(:current_user) | 203 | assert_equal users(:ze), @controller.send(:current_user) |
204 | end | 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 | should 'provide a "I forget my password" link at the login page' do | 216 | should 'provide a "I forget my password" link at the login page' do |
207 | get :login | 217 | get :login |
208 | assert_tag :tag => 'a', :attributes => { | 218 | assert_tag :tag => 'a', :attributes => { |