Skip to content

Commit

Permalink
[User] Add .broadcast_revoke_sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
NickLaMuro committed Sep 28, 2020
1 parent 32512b5 commit 7446bc3
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,21 @@ def link_user_to_session(request)
sessions << Session.find_or_create_by(:session_id => session_id)
end

def broadcast_revoke_sessions
if Settings.server.session_store = "cache"
MiqQueue.broadcast(
:class_name => self.class.name,
:instance_id => id,
:method_name => :revoke_sessions
)
else
# If using SQL or Memory, the sessions don't need to (or can't) be
# revoked via a broadcast since the session/token stores are not server
# specific, so execute it inline.
revoke_sessions
end
end

def revoke_sessions
current_sessions = Session.where(:user_id => id)
ManageIQ::Session.revoke(current_sessions.map(&:session_id))
Expand Down

0 comments on commit 7446bc3

Please sign in to comment.