Sha256: feee10e05ec89374f7aa59a7200ea2caf9954efeb1226124b894e440c41db43e

Contents?: true

Size: 693 Bytes

Versions: 10

Compression:

Stored size: 693 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

10 entries across 10 versions & 1 rubygems

Version Path
authenticate-0.7.3 lib/authenticate/callbacks/timeoutable.rb
authenticate-0.7.2 lib/authenticate/callbacks/timeoutable.rb
authenticate-0.7.1 lib/authenticate/callbacks/timeoutable.rb
authenticate-0.7.0 lib/authenticate/callbacks/timeoutable.rb
authenticate-0.6.1 lib/authenticate/callbacks/timeoutable.rb
authenticate-0.6.0 lib/authenticate/callbacks/timeoutable.rb
authenticate-0.5.0 lib/authenticate/callbacks/timeoutable.rb
authenticate-0.4.0 lib/authenticate/callbacks/timeoutable.rb
authenticate-0.3.3 lib/authenticate/callbacks/timeoutable.rb
authenticate-0.3.2 lib/authenticate/callbacks/timeoutable.rb