Sha256: b888dba24dc7f53db5e21b960ed19b461e03a0d51e8e9479d00861655b5bcbdc

Contents?: true

Size: 651 Bytes

Versions: 5

Compression:

Stored size: 651 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, I18n.t('callbacks.timeoutable.failure')) if user.timedout?
    user.last_access_at = Time.now.utc
    user.save!
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
authenticate-0.3.1 lib/authenticate/callbacks/timeoutable.rb
authenticate-0.3.0 lib/authenticate/callbacks/timeoutable.rb
authenticate-0.2.3 lib/authenticate/callbacks/timeoutable.rb
authenticate-0.2.2 lib/authenticate/callbacks/timeoutable.rb
authenticate-0.2.1 lib/authenticate/callbacks/timeoutable.rb