diff options
Diffstat (limited to 'app/controllers/api_keys_controller.rb')
| -rw-r--r-- | app/controllers/api_keys_controller.rb | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/app/controllers/api_keys_controller.rb b/app/controllers/api_keys_controller.rb index 35a84da87..7059cf52e 100644 --- a/app/controllers/api_keys_controller.rb +++ b/app/controllers/api_keys_controller.rb @@ -1,22 +1,32 @@ -class ApiKeysController < ChouetteController - defaults :resource_class => Api::V1::ApiKey - - belongs_to :referential +class ApiKeysController < BreadcrumbController + defaults resource_class: Api::V1::ApiKey def create - create! { referential_path(@referential) } + @api_key = Api::V1::ApiKey.new(api_key_params.merge(organisation: current_organisation)) + create! { organisation_api_keys_path } + end + + def index + @api_keys = decorate_api_keys(current_organisation.api_keys.paginate(page: params[:page])) end + def update - update! { referential_path(@referential) } + update! { organisation_api_key_path(resource) } end + def destroy - destroy! { referential_path(@referential) } + destroy! { organisation_api_keys_path } end private def api_key_params - params.require(:api_key).permit( :name ) - end - -end + params.require(:api_key).permit(:name, :referential_id) + end + def decorate_api_keys(api_keys) + ModelDecorator.decorate( + api_keys, + with: ApiKeyDecorator, + ) + end +end |
