api_tokens_controller: extract disallow_procedure

This commit is contained in:
simon lehericey 2023-09-13 10:30:47 +02:00
parent 2a109d3aa4
commit 9b440b6c44

View file

@ -12,9 +12,8 @@ class APITokensController < ApplicationController
end
def update
disallow_procedure_id = api_token_params.fetch(:disallow_procedure_id, nil)
if disallow_procedure_id.present?
@api_token.disallow_procedure(disallow_procedure_id.to_i)
@api_token.untarget_procedure(disallow_procedure_id.to_i)
else
@api_token.update!(api_token_params)
end
@ -40,6 +39,10 @@ class APITokensController < ApplicationController
@api_token = current_administrateur.api_tokens.find(params[:id])
end
def disallow_procedure_id
api_token_params[:disallow_procedure_id]
end
def api_token_params
params.require(:api_token).permit(:name, :write_access, :disallow_procedure_id, allowed_procedure_ids: [])
end