Skip to content

Commit

Permalink
Link user to the sessions create to enable lookup of all sessions by …
Browse files Browse the repository at this point in the history
…user

Fixes ManageIQ#20476
  • Loading branch information
gtanzillo authored and NickLaMuro committed Sep 22, 2020
1 parent 50465b4 commit c2b6cb7
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class User < ApplicationRecord
has_many :unseen_notification_recipients, -> { unseen }, :class_name => 'NotificationRecipient'
has_many :unseen_notifications, :through => :unseen_notification_recipients, :source => :notification
has_many :authentications, :foreign_key => :evm_owner_id, :dependent => :nullify, :inverse_of => :evm_owner
has_many :sessions, :dependent => :destroy
belongs_to :current_group, :class_name => "MiqGroup"
has_and_belongs_to_many :miq_groups
scope :superadmins, lambda {
Expand Down Expand Up @@ -206,7 +207,17 @@ def self.authenticator(username = nil)
end

def self.authenticate(username, password, request = nil, options = {})
authenticator(username).authenticate(username, password, request, options)
user = authenticator(username).authenticate(username, password, request, options)
user.try(:link_user_to_session, request)

user
end

def link_user_to_session(request)
return unless request

session_id = request.session_options[:id]
sessions << Session.find_or_create_by(:session_id => session_id)
end

def self.authenticate_with_http_basic(username, password, request = nil, options = {})
Expand Down

0 comments on commit c2b6cb7

Please sign in to comment.