Sha256: 903d6a02a0c7b6682329851b3a5bfca65dd70ac5d75ed8c50980561a2fd80e08
Contents?: true
Size: 1.31 KB
Versions: 2
Compression:
Stored size: 1.31 KB
Contents
# frozen_string_literal: true # Each time a record is set we check whether its session has already timed out # or not, based on last request time. If so, the record is logged out and # redirected to the sign in page. Also, each time the request comes and the # record is set, we set the last request time inside its scoped session to # verify timeout in the following request. Warden::Manager.after_set_user do |record, warden, options| scope = options[:scope] env = warden.request.env if record && record.respond_to?(:timedout?) && warden.authenticated?(scope) && options[:store] != false && !env['kingsman.skip_timeoutable'] last_request_at = warden.session(scope)['last_request_at'] if last_request_at.is_a? Integer last_request_at = Time.at(last_request_at).utc elsif last_request_at.is_a? String last_request_at = Time.parse(last_request_at) end proxy = Kingsman::Hooks::Proxy.new(warden) if !env['kingsman.skip_timeout'] && record.timedout?(last_request_at) && !proxy.remember_me_is_active?(record) Kingsman.sign_out_all_scopes ? proxy.sign_out : proxy.sign_out(scope) throw :warden, scope: scope, message: :timeout end unless env['kingsman.skip_trackable'] warden.session(scope)['last_request_at'] = Time.now.utc.to_i end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
kingsman-0.1.1 | lib/kingsman/hooks/timeoutable.rb |
kingsman-0.1.0 | lib/kingsman/hooks/timeoutable.rb |