1 class ApiController
< ApplicationController
2 protect_from_forgery with
: :null_session
3 skip_before_action
:verify_authenticity_token
5 rescue_from ActiveRecord
::RecordInvalid do |e
|
6 render json
: { error
: e
.to_s
}, status
: 422
9 rescue_from ActiveRecord
::RecordNotFound do
10 render json
: { error
: 'Record not found' }, status
: 404
13 rescue_from Goldfinger
::Error do
14 render json
: { error
: 'Remote account could not be resolved' }, status
: 422
17 rescue_from HTTP
::Error do
18 render json
: { error
: 'Remote data could not be fetched' }, status
: 503
21 rescue_from OpenSSL
::SSL::SSLError do
22 render json
: { error
: 'Remote SSL certificate could not be verified' }, status
: 503
27 def current_resource_owner
28 User
.find(doorkeeper_token
.resource_owner_id
) if doorkeeper_token
32 super || current_resource_owner
36 render json
: {}, status
: 200