Sha256: 445b7721a495469ea918eab37fe75819bf281b81c9628b9c72a4bd0561d95ddc
Contents?: true
Size: 1007 Bytes
Versions: 9
Compression:
Stored size: 1007 Bytes
Contents
# 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] if record && record.respond_to?(:timedout?) && warden.authenticated?(scope) && options[:store] != false last_request_at = warden.session(scope)['last_request_at'] if record.timedout?(last_request_at) warden.logout(scope) record.reset_authentication_token! if record.respond_to?(:reset_authentication_token!) && record.expire_auth_token_on_timeout throw :warden, :scope => scope, :message => :timeout end unless warden.request.env['devise.skip_trackable'] warden.session(scope)['last_request_at'] = Time.now.utc end end end
Version data entries
9 entries across 9 versions & 4 rubygems