2020-09-14 23:09:24 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class AuthenticationEvent < ApplicationRecord
|
2020-09-18 20:09:50 -04:00
|
|
|
include UsageStatistics
|
|
|
|
|
2020-09-14 23:09:24 -04:00
|
|
|
belongs_to :user, optional: true
|
|
|
|
|
|
|
|
validates :provider, :user_name, :result, presence: true
|
2020-09-24 11:09:51 -04:00
|
|
|
validates :ip_address, ip_address: true
|
2020-09-14 23:09:24 -04:00
|
|
|
|
|
|
|
enum result: {
|
|
|
|
failed: 0,
|
|
|
|
success: 1
|
|
|
|
}
|
2020-09-18 20:09:50 -04:00
|
|
|
|
|
|
|
scope :for_provider, ->(provider) { where(provider: provider) }
|
|
|
|
scope :ldap, -> { where('provider LIKE ?', 'ldap%')}
|
|
|
|
|
|
|
|
def self.providers
|
|
|
|
distinct.pluck(:provider)
|
|
|
|
end
|
2020-09-14 23:09:24 -04:00
|
|
|
end
|