Fixes #3614 - Log if a active user (in UI) has been logged out due to SessionTimeout.
This commit is contained in:
parent
d2e1229335
commit
651f4e819e
1 changed files with 12 additions and 4 deletions
|
@ -3,8 +3,6 @@
|
|||
class SessionTimeoutJob::Session
|
||||
attr_accessor :session, :user
|
||||
|
||||
delegate :destroy, to: :session
|
||||
|
||||
def initialize(session)
|
||||
@session = session
|
||||
@user = User.find_by(id: session.data['user_id'])
|
||||
|
@ -15,7 +13,6 @@ class SessionTimeoutJob::Session
|
|||
end
|
||||
|
||||
def active?
|
||||
return true if !user?
|
||||
return true if timeout < 1
|
||||
return true if session.data['ping'] > timeout.seconds.ago
|
||||
end
|
||||
|
@ -27,7 +24,13 @@ class SessionTimeoutJob::Session
|
|||
end
|
||||
|
||||
def timeout
|
||||
@timeout ||= begin
|
||||
return -1 if !user?
|
||||
|
||||
timeout_user
|
||||
end
|
||||
|
||||
def timeout_user
|
||||
@timeout_user ||= begin
|
||||
permissions = Permission.where(id: user.permissions_with_child_ids).pluck(:name)
|
||||
|
||||
result = -1
|
||||
|
@ -50,4 +53,9 @@ class SessionTimeoutJob::Session
|
|||
def config
|
||||
Setting.get('session_timeout')
|
||||
end
|
||||
|
||||
def destroy
|
||||
session.destroy
|
||||
Rails.logger.info "SessionTimeoutJob removed session '#{session.id}' for user id '#{user&.id}' (last ping: '#{session.data['ping']}', timeout: '#{timeout.seconds}')"
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue