Class: Warden::OAuth2::FailureApp

Inherits:
Object
  • Object
show all
Defined in:
lib/warden/oauth2/failure_app.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.call(env) ⇒ Object



5
6
7
# File 'lib/warden/oauth2/failure_app.rb', line 5

def self.call(env)
  new.call(env)
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/warden/oauth2/failure_app.rb', line 9

def call(env)
  warden = env['warden']
  strategy = warden.winning_strategy
  error_description = strategy.respond_to?(:error_description) ? strategy.error_description : ''

  body = {}
  body[:error] = strategy.message
  body[:error_description] = error_description
  body = JSON.dump(body)
  status = strategy.error_status
  headers = {'Content-Type' => 'application/json'}

  headers['X-Accepted-OAuth-Scopes'] = (strategy.scope || :public).to_s

  [status, headers, [body]]
end