Module: OmniAuth::Identity::Model::ClassMethods

Defined in:
lib/omniauth/identity/model.rb

Instance Method Summary collapse

Instance Method Details

#auth_key(method = false) ⇒ String

Used to set or retrieve the method that will be used to get and set the user-supplied authentication key.

Returns:

  • (String)

    The method name.



52
53
54
55
56
57
# File 'lib/omniauth/identity/model.rb', line 52

def auth_key(method = false)
  @auth_key = method.to_s unless method == false
  @auth_key = nil if !defined?(@auth_key) || @auth_key == ""

  @auth_key || "email"
end

#authenticate(conditions, password) ⇒ Model, false

Authenticate a user with the given key and password.

Parameters:

  • conditions (String)

    The unique login key provided for a given identity.

  • password (String)

    The presumed password for the identity.

Returns:

  • (Model, false)

    An instance of the identity model class.



42
43
44
45
46
47
# File 'lib/omniauth/identity/model.rb', line 42

def authenticate(conditions, password)
  instance = locate(conditions)
  return false unless instance

  instance.authenticate(password)
end

#locate(_key) ⇒ Model

This method is abstract.

Locate an identity given its unique login key.

Parameters:

  • _key (String)

    The unique login key.

Returns:

  • (Model)

    An instance of the identity model class.

Raises:

  • (NotImplementedError)


64
65
66
# File 'lib/omniauth/identity/model.rb', line 64

def locate(_key)
  raise NotImplementedError
end