Module: EndPointBlank::Rails::Authorized

Extended by:
ActiveSupport::Concern
Defined in:
lib/end_point_blank/rails/authorized.rb

Instance Method Summary collapse

Instance Method Details

#authorize!Object



12
13
14
15
16
17
18
19
20
# File 'lib/end_point_blank/rails/authorized.rb', line 12

def authorize!
  result = EndPointBlank::Commands::EndpointAuthorize.authorize(request)
  if result.nil? || result.status != 201
    raise UnauthorizedError.new(authorize_error_message(result), result&.status || 503)
  end
  result_json = JSON.parse(result.body)
  app_env_id = result_json['data'][0]['source_application_environment_id']
  ::EndPointBlank::Rack::EnvStore.set_source_application_environment_id(app_env_id)
end