summaryrefslogtreecommitdiffstats
path: root/app/controllers/my_controller.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2013-08-05 17:58:33 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2013-08-05 17:58:33 +0000
commitb764e398475c26217bcca8ac9063f053bc1cf627 (patch)
treef8c44b9b990ff60f3cf51fe65bb8dad9dae8bd35 /app/controllers/my_controller.rb
parentbd4fba08e5bec539a746e9be422b9c2baab51406 (diff)
downloadredmine-b764e398475c26217bcca8ac9063f053bc1cf627.tar.gz
redmine-b764e398475c26217bcca8ac9063f053bc1cf627.zip
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
Diffstat (limited to 'app/controllers/my_controller.rb')
-rw-r--r--app/controllers/my_controller.rb11
1 files changed, 8 insertions, 3 deletions
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