2020-11-24 15:15:51 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class AuthenticationEvent < ApplicationRecord
|
2021-01-03 14:25:43 +05:30
|
|
|
include UsageStatistics
|
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
belongs_to :user, optional: true
|
|
|
|
|
|
|
|
validates :provider, :user_name, :result, presence: true
|
2021-01-03 14:25:43 +05:30
|
|
|
validates :ip_address, ip_address: true
|
2020-11-24 15:15:51 +05:30
|
|
|
|
|
|
|
enum result: {
|
|
|
|
failed: 0,
|
|
|
|
success: 1
|
|
|
|
}
|
2021-01-03 14:25:43 +05:30
|
|
|
|
|
|
|
scope :for_provider, ->(provider) { where(provider: provider) }
|
|
|
|
scope :ldap, -> { where('provider LIKE ?', 'ldap%')}
|
|
|
|
|
|
|
|
def self.providers
|
|
|
|
distinct.pluck(:provider)
|
|
|
|
end
|
2020-11-24 15:15:51 +05:30
|
|
|
end
|