module TokAccess::TokAuthenticable::ClassMethods
Public Instance Methods
tok_authentication(object, password)
click to toggle source
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
# File lib/tok_access/tok_authenticable.rb, line 124 def tok_authentication(object, password) return object.tok_auth(password) end
validate_access(tokens = {})
click to toggle source
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
# 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