From b764e398475c26217bcca8ac9063f053bc1cf627 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Mon, 5 Aug 2013 17:58:33 +0000 Subject: Option to force a user to change his password (#3872). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@12081 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/my_controller.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'app/controllers/my_controller.rb') diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index 5328991b3..82532918a 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -17,6 +17,8 @@ class MyController < ApplicationController before_filter :require_login + # let user change his password when he has to + skip_before_filter :check_password_change, :only => :password helper :issues helper :users @@ -90,14 +92,17 @@ class MyController < ApplicationController return end if request.post? - if @user.check_password?(params[:password]) + if !@user.check_password?(params[:password]) + flash.now[:error] = l(:notice_account_wrong_password) + elsif params[:password] == params[:new_password] + flash.now[:error] = 'Your new password must be different from your current password' + else @user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation] + @user.must_change_passwd = false if @user.save flash[:notice] = l(:notice_account_password_updated) redirect_to my_account_path end - else - flash[:error] = l(:notice_account_wrong_password) end end end -- cgit v1.2.3