Class: TentD::API::Apps::AuthorizationTokenExchange

Inherits:
Middleware
  • Object
show all
Defined in:
lib/tentd/api/apps.rb

Instance Method Summary collapse

Methods inherited from Middleware

#call, #initialize

Methods included from TentD::API::Authorizable

#authorize_env!, #authorize_env?

Constructor Details

This class inherits a constructor from TentD::API::Middleware

Instance Method Details

#action(env) ⇒ Object



103
104
105
106
107
108
109
110
# File 'lib/tentd/api/apps.rb', line 103

def action(env)
  if authorization = Model::AppAuthorization.first(:app_id => env.params.app_id, :token_code => env.params.data.code)
    env.response = authorization.token_exchange!
  else
    raise Unauthorized
  end
  env
end