otvorenesudy/otvorenesudy-api

View on GitHub
app/controllers/concerns/api/authorizable.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
module Api::Authorizable
  extend ActiveSupport::Concern

  included do
    before_action :check_api_key
  end

  private

  def check_api_key
    unless Api::Key.exists? value: params[:api_key]
      render status: 401, json: { success: false, errors: ['Invalid API Key'] }
    end
  end
end