login_activity.rb 762 B

1234567891011121314151617181920212223242526
  1. # frozen_string_literal: true
  2. # == Schema Information
  3. #
  4. # Table name: login_activities
  5. #
  6. # id :bigint(8) not null, primary key
  7. # user_id :bigint(8) not null
  8. # authentication_method :string
  9. # provider :string
  10. # success :boolean
  11. # failure_reason :string
  12. # ip :inet
  13. # user_agent :string
  14. # created_at :datetime
  15. #
  16. class LoginActivity < ApplicationRecord
  17. include BrowserDetection
  18. enum :authentication_method, { password: 'password', otp: 'otp', webauthn: 'webauthn', sign_in_token: 'sign_in_token', omniauth: 'omniauth' }
  19. belongs_to :user
  20. validates :authentication_method, inclusion: { in: authentication_methods.keys }
  21. end