Adds methods to User model to handle tokens.

git-svn-id: http://svn.redmine.org/redmine/trunk@16474 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2017-04-04 17:15:07 +00:00
parent 5c7aaa4d1e
commit b9ee00a8c8
3 changed files with 20 additions and 5 deletions

View File

@@ -168,9 +168,10 @@ class ApplicationController < ActionController::Base
# Logs out current user
def logout_user
if User.current.logged?
cookies.delete(autologin_cookie_name)
Token.where(["user_id = ? AND action = ?", User.current.id, 'autologin']).delete_all
Token.where(["user_id = ? AND action = ? AND value = ?", User.current.id, 'session', session[:tk]]).delete_all
if autologin = cookies.delete(autologin_cookie_name)
User.current.delete_autologin_token(autologin)
end
User.current.delete_session_token(session[:tk])
self.logged_user = nil
end
end