diff options
author | Jean-Baptiste Barth <jeanbaptiste.barth@gmail.com> | 2014-09-16 21:38:54 +0000 |
---|---|---|
committer | Jean-Baptiste Barth <jeanbaptiste.barth@gmail.com> | 2014-09-16 21:38:54 +0000 |
commit | b519aba63ee0043ffd60f9002fc236f717d9f172 (patch) | |
tree | 4e8a47e052704bc97318550c316138c2c3977d87 /app/controllers/application_controller.rb | |
parent | e632a79d59fc90ef0076f741f16b84fb689b99df (diff) | |
download | redmine-b519aba63ee0043ffd60f9002fc236f717d9f172.tar.gz redmine-b519aba63ee0043ffd60f9002fc236f717d9f172.zip |
Expire other sessions on password change (#17796).
Contributed by Jan Schulz-Hofen.
git-svn-id: http://svn.redmine.org/redmine/trunk@13412 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/application_controller.rb')
-rw-r--r-- | app/controllers/application_controller.rb | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e70f1602c..e8f3565ee 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -49,7 +49,7 @@ class ApplicationController < ActionController::Base end end - before_filter :session_expiration, :user_setup, :check_if_login_required, :check_password_change, :set_localization + before_filter :session_expiration, :user_setup, :force_logout_if_password_changed, :check_if_login_required, :check_password_change, :set_localization rescue_from ::Unauthorized, :with => :deny_access rescue_from ::ActionView::MissingTemplate, :with => :missing_template @@ -145,6 +145,18 @@ class ApplicationController < ActionController::Base user end + def force_logout_if_password_changed + passwd_changed_on = User.current.passwd_changed_on || Time.at(0) + # Make sure we force logout only for web browser sessions, not API calls + # if the password was changed after the session creation. + if session[:user_id] && passwd_changed_on.utc.to_i > session[:ctime].to_i + reset_session + set_localization + flash[:error] = l(:error_session_expired) + redirect_to signin_url + end + end + def autologin_cookie_name Redmine::Configuration['autologin_cookie_name'].presence || 'autologin' end |