class Rodauth::Rails::Model::Associations

Attributes

rodauth[R]

Public Class Methods

call(rodauth) click to toggle source
# File lib/rodauth/rails/model/associations.rb, line 7
def self.call(rodauth)
  new(rodauth).call
end
new(rodauth) click to toggle source
# File lib/rodauth/rails/model/associations.rb, line 11
def initialize(rodauth)
  @rodauth = rodauth
end

Public Instance Methods

call() click to toggle source
# File lib/rodauth/rails/model/associations.rb, line 15
def call
  rodauth.features
    .select { |feature| respond_to?(feature, true) }
    .flat_map { |feature| send(feature) }
end

Private Instance Methods

account_expiration() click to toggle source
# File lib/rodauth/rails/model/associations.rb, line 85
def account_expiration
  {
    name: :activity_time,
    type: :has_one,
    table: rodauth.account_activity_table,
    foreign_key: rodauth.account_activity_id_column,
  }
end
active_sessions() click to toggle source
# File lib/rodauth/rails/model/associations.rb, line 94
def active_sessions
  {
    name: :active_session_keys,
    type: :has_many,
    table: rodauth.active_sessions_table,
    foreign_key: rodauth.active_sessions_account_id_column,
  }
end
audit_logging() click to toggle source
# File lib/rodauth/rails/model/associations.rb, line 103
def audit_logging
  {
    name: :authentication_audit_logs,
    type: :has_many,
    table: rodauth.audit_logging_table,
    foreign_key: rodauth.audit_logging_account_id_column,
    dependent: nil,
  }
end
disallow_password_reuse() click to toggle source
# File lib/rodauth/rails/model/associations.rb, line 113
def disallow_password_reuse
  {
    name: :previous_password_hashes,
    type: :has_many,
    table: rodauth.previous_password_hash_table,
    foreign_key: rodauth.previous_password_account_id_column,
  }
end
email_auth() click to toggle source
# File lib/rodauth/rails/model/associations.rb, line 76
def email_auth
  {
    name: :email_auth_key,
    type: :has_one,
    table: rodauth.email_auth_table,
    foreign_key: rodauth.email_auth_id_column,
  }
end
jwt_refresh() click to toggle source
# File lib/rodauth/rails/model/associations.rb, line 122
def jwt_refresh
  {
    name: :jwt_refresh_keys,
    type: :has_many,
    table: rodauth.jwt_refresh_token_table,
    foreign_key: rodauth.jwt_refresh_token_account_id_column,
  }
end
lockout() click to toggle source
# File lib/rodauth/rails/model/associations.rb, line 59
def lockout
  [
    {
      name: :lockout,
      type: :has_one,
      table: rodauth.account_lockouts_table,
      foreign_key: rodauth.account_lockouts_id_column,
    },
    {
      name: :login_failure,
      type: :has_one,
      table: rodauth.account_login_failures_table,
      foreign_key: rodauth.account_login_failures_id_column,
    }
  ]
end
otp() click to toggle source
# File lib/rodauth/rails/model/associations.rb, line 149
def otp
  {
    name: :otp_key,
    type: :has_one,
    table: rodauth.otp_keys_table,
    foreign_key: rodauth.otp_keys_id_column,
  }
end
password_expiration() click to toggle source
# File lib/rodauth/rails/model/associations.rb, line 131
def password_expiration
  {
    name: :password_change_time,
    type: :has_one,
    table: rodauth.password_expiration_table,
    foreign_key: rodauth.password_expiration_id_column,
  }
end
recovery_codes() click to toggle source
# File lib/rodauth/rails/model/associations.rb, line 167
def recovery_codes
  {
    name: :recovery_codes,
    type: :has_many,
    table: rodauth.recovery_codes_table,
    foreign_key: rodauth.recovery_codes_id_column,
  }
end
remember() click to toggle source
# File lib/rodauth/rails/model/associations.rb, line 23
def remember
  {
    name: :remember_key,
    type: :has_one,
    table: rodauth.remember_table,
    foreign_key: rodauth.remember_id_column,
  }
end
reset_password() click to toggle source
# File lib/rodauth/rails/model/associations.rb, line 41
def reset_password
  {
    name: :password_reset_key,
    type: :has_one,
    table: rodauth.reset_password_table,
    foreign_key: rodauth.reset_password_id_column,
  }
end
single_session() click to toggle source
# File lib/rodauth/rails/model/associations.rb, line 140
def single_session
  {
    name: :session_key,
    type: :has_one,
    table: rodauth.single_session_table,
    foreign_key: rodauth.single_session_id_column,
  }
end
sms_codes() click to toggle source
# File lib/rodauth/rails/model/associations.rb, line 158
def sms_codes
  {
    name: :sms_code,
    type: :has_one,
    table: rodauth.sms_codes_table,
    foreign_key: rodauth.sms_id_column,
  }
end
verify_account() click to toggle source
# File lib/rodauth/rails/model/associations.rb, line 32
def verify_account
  {
    name: :verification_key,
    type: :has_one,
    table: rodauth.verify_account_table,
    foreign_key: rodauth.verify_account_id_column,
  }
end
verify_login_change() click to toggle source
# File lib/rodauth/rails/model/associations.rb, line 50
def verify_login_change
  {
    name: :login_change_key,
    type: :has_one,
    table: rodauth.verify_login_change_table,
    foreign_key: rodauth.verify_login_change_id_column,
  }
end
webauthn() click to toggle source
# File lib/rodauth/rails/model/associations.rb, line 176
def webauthn
  [
    {
      name: :webauthn_user_id,
      type: :has_one,
      table: rodauth.webauthn_user_ids_table,
      foreign_key: rodauth.webauthn_user_ids_account_id_column,
    },
    {
      name: :webauthn_keys,
      type: :has_many,
      table: rodauth.webauthn_keys_table,
      foreign_key: rodauth.webauthn_keys_account_id_column,
    }
  ]
end