Commit 83006eed authored by mgabdev's avatar mgabdev

Updated EmptyController to have protections and error responses

• Updated:
- EmptyController to have protections and error responses
parent 297fac5d
......@@ -2,6 +2,38 @@
class EmptyController < ActionController::Base
include RateLimitHeaders
protect_from_forgery with: :null_session
rescue_from ActiveRecord::RecordInvalid, GabSocial::ValidationError do |e|
render json: { error: e.to_s }, status: 422
end
rescue_from ActiveRecord::RecordNotFound do
render json: { error: 'Record not found' }, status: 404
end
rescue_from HTTP::Error, GabSocial::UnexpectedResponseError do
render json: { error: 'Remote data could not be fetched' }, status: 503
end
rescue_from OpenSSL::SSL::SSLError do
render json: { error: 'Remote SSL certificate could not be verified' }, status: 503
end
rescue_from GabSocial::NotPermittedError do
render json: { error: 'This action is not allowed' }, status: 403
end
def doorkeeper_unauthorized_render_options(error: nil)
{ json: { error: (error.try(:description) || 'Not authorized') } }
end
def doorkeeper_forbidden_render_options(*)
{ json: { error: 'This action is outside the authorized scopes' } }
end
protected
def current_user
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment