You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
543 B

  1. class ApiController < ApplicationController
  2. protect_from_forgery with: :null_session
  3. skip_before_action :verify_authenticity_token
  4. rescue_from ActiveRecord::RecordInvalid do
  5. render json: { error: 'Record invalid' }, status: 422
  6. end
  7. rescue_from ActiveRecord::RecordNotFound do
  8. render json: { error: 'Record not found' }, status: 404
  9. end
  10. protected
  11. def current_resource_owner
  12. User.find(doorkeeper_token.resource_owner_id) if doorkeeper_token
  13. end
  14. def current_user
  15. super || current_resource_owner
  16. end
  17. end