Files
openfoodnetwork/app/controllers/api/customers_controller.rb
Pau Pérez Fabregat fd95ae7e41 Merge pull request #3847 from Matt-Yorkley/api_access
Allow unauthenticated access to OFN API endpoints
2019-06-12 09:45:11 +02:00

22 lines
540 B
Ruby

module Api
class CustomersController < BaseController
skip_authorization_check only: :index
def index
@customers = current_api_user.customers
render json: @customers, each_serializer: CustomerSerializer
end
def update
@customer = Customer.find(params[:id])
authorize! :update, @customer
if @customer.update_attributes(params[:customer])
render json: @customer, serializer: CustomerSerializer, status: :ok
else
invalid_resource!(@customer)
end
end
end
end