Module: TokAccess::TokAuthenticable::ClassMethods
- Defined in:
- lib/tok_access/tok_authenticable.rb
Instance Method Summary collapse
-
#tok_authentication(object, password) ⇒ Object
object: The object to authenticate password: The password to authenticate the object with if the object is authenticatred successfully, returns the object with => the get_token and get_device_token methods returning the access => tokens.
-
#validate_access(tokens = {}) ⇒ Object
tokens: hash with a device_token key or token key if any of the tokens is found.
Instance Method Details
#tok_authentication(object, password) ⇒ Object
object: The object to authenticate password: The password to authenticate the object with if the object is authenticatred successfully, returns the object with
> the get_token and get_device_token methods returning the access
> tokens.
otherwise return nil
124 125 126 |
# File 'lib/tok_access/tok_authenticable.rb', line 124 def tok_authentication(object, password) return object.tok_auth(password) end |
#validate_access(tokens = {}) ⇒ Object
tokens: hash with a device_token key or token key if any of the tokens is found. Provide access to the related object calling the method provide_access otherwise return nil
132 133 134 135 136 137 138 139 140 |
# File 'lib/tok_access/tok_authenticable.rb', line 132 def validate_access(tokens = {}) toks_class = Object.const_get("#{self.name.camelize}Tok") tok = toks_class.find_by(device_token: tokens[:device_token]) if tokens[:device_token] tok = toks_class.find_by(token: tokens[:token]) if tokens[:token] and !tok if tok return tok._tok_object.provide_access(tok) end nil end |