Class: DeviseLoginza::Loginza

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/devise_loginza/loginza.rb

Class Method Summary collapse

Class Method Details

.auth(token) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/devise_loginza/loginza.rb', line 14

def auth(token)
  response = get('/api/authinfo', :query => { :token => token})

  raise ServiceUnavailableError, "The Loginza service is temporarily unavailable. (4XX)" if response.code >= 400
  @data = JSON.parse(response.body)

  {
    :auth_state   => (@data.keys.join =~ /error/ ? :error : :ok),
    :data         => @data
  }
rescue Exception => e
  ::Rails.logger.info("Error parse: #{response.body}")
  ::Rails.logger.error(e)
  return { }
end