Class: AuthenticationEvent

Inherits:
MainClusterwide::ApplicationRecord show all
Includes:
UsageStatistics
Defined in:
app/models/authentication_event.rb

Constant Summary collapse

TWO_FACTOR =
'two-factor'
TWO_FACTOR_U2F =
'two-factor-via-u2f-device'
TWO_FACTOR_WEBAUTHN =
'two-factor-via-webauthn-device'
STANDARD =
'standard'
STATIC_PROVIDERS =
[TWO_FACTOR, TWO_FACTOR_U2F, TWO_FACTOR_WEBAUTHN, STANDARD].freeze

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

Constants included from ResetOnUnionError

ResetOnUnionError::MAX_RESET_PERIOD

Class Method Summary collapse

Methods inherited from ApplicationRecord

cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order

Methods included from SensitiveSerializableHash

#serializable_hash

Class Method Details

.initial_login_or_known_ip_address?(user, ip_address) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
32
# File 'app/models/authentication_event.rb', line 29

def self.(user, ip_address)
  !where(user_id: user).exists? ||
    where(user_id: user, ip_address: ip_address).success.exists?
end

.most_used_ip_address_for_user(user) ⇒ Object



34
35
36
# File 'app/models/authentication_event.rb', line 34

def self.most_used_ip_address_for_user(user)
  select('mode() within group (order by ip_address) as ip_address').find_by(user: user).ip_address
end

.providersObject



25
26
27
# File 'app/models/authentication_event.rb', line 25

def self.providers
  STATIC_PROVIDERS | Devise.omniauth_providers.map(&:to_s)
end