Class: OmniAuth::Strategies::Exvo

Inherits:
OAuth2
  • Object
show all
Defined in:
lib/omniauth/strategies/exvo.rb

Instance Method Summary collapse

Instance Method Details

#callback_keyObject



26
27
28
# File 'lib/omniauth/strategies/exvo.rb', line 26

def callback_key
  '_callback'
end

#callback_phaseObject



21
22
23
24
# File 'lib/omniauth/strategies/exvo.rb', line 21

def callback_phase
  set_failure_handler
  super
end

#callback_urlObject



30
31
32
33
34
35
36
# File 'lib/omniauth/strategies/exvo.rb', line 30

def callback_url
  if interactive?
    super
  else
    super + "?" + Rack::Utils.build_query(callback_key => request[callback_key])
  end
end

#interactive?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/omniauth/strategies/exvo.rb', line 38

def interactive?
  !non_interactive?
end

#non_interactive?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/omniauth/strategies/exvo.rb', line 42

def non_interactive?
  !!request[callback_key]
end

#raw_infoObject



61
62
63
64
65
# File 'lib/omniauth/strategies/exvo.rb', line 61

def raw_info
  access_token.options[:mode] = :query
  access_token.options[:param_name] = :access_token
  @raw_info ||= access_token.get('/user.json').parsed
end

#request_phaseObject



14
15
16
17
18
19
# File 'lib/omniauth/strategies/exvo.rb', line 14

def request_phase
  %w(scope x_sign_up).each do |param|
    options[:authorize_params][param.to_sym] = request[param] if request[param]
  end
  super
end

#set_failure_handlerObject



67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/omniauth/strategies/exvo.rb', line 67

def set_failure_handler
  OmniAuth.config.on_failure =
    if interactive?
      Proc.new do |env|
        message_key = env['omniauth.error.type']
        new_path = "#{env['SCRIPT_NAME']}#{OmniAuth.config.path_prefix}/failure?message=#{message_key}"
        [302, { 'Location' => new_path, 'Content-Type'=> 'text/html' }, []]
      end
    else
      OmniAuth.config.on_failure = Proc.new do |env|
        [401, { 'Content-Type' => 'application/javascript' }, [MultiJson.encode(:error => env['omniauth.error.type'])]]
      end
    end
end