Method: ElsToken::ClassMethods#get_identity

Defined in:
lib/els_token.rb

#get_identity(token, options = {}) ⇒ Object

When used inside a rack environment will attempt to retrieve the user token from the session cookie and return a full identity. This is pretty much a convenience method that chains is_cookie_token_valid? then get_token_identity



129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/els_token.rb', line 129

def get_identity(token, options ={})
  options = els_options.dup.merge(options)
  return fake_id(options) if options.has_key?('faker')
  begin
    if is_token_valid?(token, options)
      get_token_identity(token, options)
    else
      raise "token is invalid"
    end
  rescue Exception => e
    raise e
  end
end