Class: AuthenticationEvent
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- AuthenticationEvent
- Includes:
- SafelyChangeColumnDefault, UsageStatistics
- Defined in:
- app/models/authentication_event.rb
Constant Summary collapse
- RETENTION_PERIOD =
1.year
- TWO_FACTOR =
'two-factor'- TWO_FACTOR_WEBAUTHN =
'two-factor-via-webauthn-device'- STANDARD =
'standard'- STATIC_PROVIDERS =
[TWO_FACTOR, TWO_FACTOR_WEBAUTHN, STANDARD].freeze
Constants inherited from ApplicationRecord
Constants included from HasCheckConstraints
HasCheckConstraints::NOT_NULL_CHECK_PATTERN
Constants included from ResetOnColumnErrors
ResetOnColumnErrors::MAX_RESET_PERIOD
Class Method Summary collapse
- .initial_login_or_known_ip_address?(user, ip_address) ⇒ Boolean
- .most_used_ip_address_for_user(user) ⇒ Object
- .providers ⇒ Object
Methods inherited from ApplicationRecord
===, cached_column_list, #create_or_load_association, current_transaction, declarative_enum, default_select_columns, delete_all_returning, #deleted_from_database?, id_in, id_not_in, iid_in, nullable_column?, 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 Organizations::Sharding
Methods included from ResetOnColumnErrors
#reset_on_union_error, #reset_on_unknown_attribute_error
Methods included from Gitlab::SensitiveSerializableHash
Class Method Details
.initial_login_or_known_ip_address?(user, ip_address) ⇒ Boolean
35 36 37 38 |
# File 'app/models/authentication_event.rb', line 35 def self.initial_login_or_known_ip_address?(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
40 41 42 |
# File 'app/models/authentication_event.rb', line 40 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 |
.providers ⇒ Object
31 32 33 |
# File 'app/models/authentication_event.rb', line 31 def self.providers STATIC_PROVIDERS | Devise.omniauth_providers.map(&:to_s) end |