Sha256: 712e866cdc313fddfeaebcc1bb6618590d9c9dc1490a4fedee4a01daf7c1d663

Contents?: true

Size: 638 Bytes

Versions: 1

Compression:

Stored size: 638 Bytes

Contents

# Update last_access_at on every authentication
Authenticate.lifecycle.after_authentication name: 'timeoutable after authentication' do |user, session, options|
  if user && user.respond_to?(:last_access_at)
    user.last_access_at = Time.now.utc
    user.save!
  end
end

# Fail users that have timed out. Otherwise update last_access_at.
Authenticate.lifecycle.after_set_user name: 'timeoutable after set_user', except: :authentication do |user, session, options|
  if user && user.respond_to?(:timedout?)
    throw(:failure, 'Your session has expired') if user.timedout?
    user.last_access_at = Time.now.utc
    user.save!
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
authenticate-0.2.0 lib/authenticate/callbacks/timeoutable.rb