Module: EasyAuth::Models::Account::ClassMethods

Defined in:
lib/easy_auth/models/account.rb

Instance Method Summary collapse

Instance Method Details

#identity_username_attributeSymbol

Will attempt to find the username attribute

First will check to see if #identity_username_attribute is already defined in the model.

If not, will check to see if ‘username` exists as a column on the record If not, will check to see if `email` exists as a column on the record

Returns:

  • (Symbol)


24
25
26
27
28
29
30
31
32
33
34
# File 'lib/easy_auth/models/account.rb', line 24

def identity_username_attribute
  if respond_to?(:super)
    super
  elsif column_names.include?('username')
    :username
  elsif column_names.include?('email')
    :email
  else
    raise EasyAuth::Models::Account::NoIdentityUsernameError, 'your model must have either a #username or #email attribute. Or you must override the .identity_username_attribute class method'
  end
end