mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-17 06:52:27 +01:00
fix refactoring issue in /api/open_api_clients
This commit is contained in:
parent
b790bc01e7
commit
5e8aeb928c
@ -11,35 +11,35 @@ class API::OpenAPIClientsController < API::ApiController
|
||||
end
|
||||
|
||||
def create
|
||||
@projets = OpenAPI::Client.new(client_params)
|
||||
authorize @projets
|
||||
if @projets.save
|
||||
@client = OpenAPI::Client.new(client_params)
|
||||
authorize @client
|
||||
if @client.save
|
||||
render status: :created
|
||||
else
|
||||
render json: @projets.errors, status: :unprocessable_entity
|
||||
render json: @client.errors, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@projets = OpenAPI::Client.find(params[:id])
|
||||
authorize @projets
|
||||
if @projets.update(client_params)
|
||||
@client = OpenAPI::Client.find(params[:id])
|
||||
authorize @client
|
||||
if @client.update(client_params)
|
||||
render status: :ok
|
||||
else
|
||||
render json: @projets.errors, status: :unprocessable_entity
|
||||
render json: @client.errors, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
def reset_token
|
||||
@projets = OpenAPI::Client.find(params[:id])
|
||||
authorize @projets
|
||||
@projets.regenerate_token
|
||||
@client = OpenAPI::Client.find(params[:id])
|
||||
authorize @client
|
||||
@client.regenerate_token
|
||||
end
|
||||
|
||||
def destroy
|
||||
@projets = OpenAPI::Client.find(params[:id])
|
||||
authorize @projets
|
||||
@projets.destroy
|
||||
@client = OpenAPI::Client.find(params[:id])
|
||||
authorize @client
|
||||
@client.destroy
|
||||
head 204
|
||||
end
|
||||
|
||||
|
@ -1 +1,3 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
json.extract! client, :id, :name, :calls_count, :token, :created_at
|
||||
|
@ -1 +1,3 @@
|
||||
json.partial! 'api/open_api_clients/client', projets: @projets
|
||||
# frozen_string_literal: true
|
||||
|
||||
json.partial! 'api/open_api_clients/client', client: @client
|
||||
|
@ -1,3 +1,3 @@
|
||||
json.array! @clients do |client|
|
||||
json.partial! 'api/open_api_clients/client', projets: client
|
||||
json.partial! 'api/open_api_clients/client', client: client
|
||||
end
|
||||
|
@ -1 +1 @@
|
||||
json.partial! 'api/open_api_clients/client', projets: @projets
|
||||
json.partial! 'api/open_api_clients/client', client: @client
|
||||
|
@ -1 +1 @@
|
||||
json.partial! 'api/open_api_clients/client', projets: @projets
|
||||
json.partial! 'api/open_api_clients/client', client: @client
|
||||
|
Loading…
x
Reference in New Issue
Block a user