Class: ExvoAuth::Strategies::NonInteractive

Inherits:
Base
  • Object
show all
Defined in:
lib/exvo_auth/strategies/non_interactive.rb

Instance Method Summary collapse

Methods inherited from Base

#auth_hash, #user_data, #user_info

Constructor Details

#initialize(app, options = {}) ⇒ NonInteractive

Returns a new instance of NonInteractive.



2
3
4
# File 'lib/exvo_auth/strategies/non_interactive.rb', line 2

def initialize(app, options = {})
  super(app, :non_interactive, options)
end

Instance Method Details

#callback_urlObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/exvo_auth/strategies/non_interactive.rb', line 14

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

#fail!(message_key) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/exvo_auth/strategies/non_interactive.rb', line 25

def fail!(message_key)
  body = MultiJson.encode(:error => "Please sign in!")
  [401, { 
    "Content-Type"   => "application/json", 
    "Content-Length" => body.length.to_s 
  }, [body]]
end

#request_phase(options = {}) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/exvo_auth/strategies/non_interactive.rb', line 6

def request_phase(options = {})
  redirect @client.non_interactive.authorize_url(unicorns_and_rainbows(
    :redirect_uri => callback_url, 
    :scope        => request["scope"], 
    :state        => request["state"]
  ))
end