diff --git a/app/commands/decidim/rest_full/create_api_client.rb b/app/commands/decidim/rest_full/create_api_client.rb
index de8824f..4c56935 100644
--- a/app/commands/decidim/rest_full/create_api_client.rb
+++ b/app/commands/decidim/rest_full/create_api_client.rb
@@ -30,7 +30,7 @@ def api_client_attributes
organization: @form.current_organization,
name: @form.name,
decidim_organization_id: @form.decidim_organization_id,
- scopes: @form.scopes.join(",")
+ scopes: @form.scopes
}
end
end
diff --git a/app/controllers/decidim/rest_full/system/api_clients_controller.rb b/app/controllers/decidim/rest_full/system/api_clients_controller.rb
index cfd2aaa..0da4cb6 100644
--- a/app/controllers/decidim/rest_full/system/api_clients_controller.rb
+++ b/app/controllers/decidim/rest_full/system/api_clients_controller.rb
@@ -5,12 +5,19 @@ module RestFull
module System
class ApiClientsController < Decidim::System::ApplicationController
helper Decidim::Admin::AttributesDisplayHelper
+ helper Decidim::Core::Engine.routes.url_helpers
helper_method :destroy_admin_session_path
-
+ def core_engine_routes
+ Decidim::Core::Engine.routes.url_helpers
+ end
def destroy_admin_session_path
Decidim::System::Engine.routes.url_helpers.destroy_admin_session_path
end
-
+ def destroy
+ @api_client = collection.find(params[:id])
+ @api_client.destroy
+ redirect_to core_engine_routes.system_api_clients_path, flash: {success: "Client Revoked"}
+ end
def index
@api_clients = collection.page(params[:page]).per(15)
end
@@ -35,7 +42,7 @@ def create
CreateApiClient.call(@form) do
on(:ok) do |api_client|
flash[:notice] = I18n.t("create.success", scope: "decidim.rest_full.system.api_clients")
- redirect_to edit_system_api_client_path(api_client)
+ redirect_to core_engine_routes.edit_system_api_client_path(api_client)
end
on(:invalid) do
diff --git a/app/forms/decidim/rest_full/api_client_form.rb b/app/forms/decidim/rest_full/api_client_form.rb
index 5f98a64..7a4d355 100644
--- a/app/forms/decidim/rest_full/api_client_form.rb
+++ b/app/forms/decidim/rest_full/api_client_form.rb
@@ -5,12 +5,11 @@ module RestFull
# The form that validates the data to construct a valid OAuthApplication.
class ApiClientForm < Decidim::Form
mimic :system_api_client
-
attribute :name, String
attribute :decidim_organization_id, Integer
attribute :scopes, [String]
validates :name, :decidim_organization_id, presence: true
-
+
def organization
current_organization || Decidim::Organization.find_by(id: decidim_organization_id)
end
diff --git a/app/views/decidim/rest_full/system/api_clients/_form.html.erb b/app/views/decidim/rest_full/system/api_clients/_form.html.erb
index 84065a4..ddc73e1 100644
--- a/app/views/decidim/rest_full/system/api_clients/_form.html.erb
+++ b/app/views/decidim/rest_full/system/api_clients/_form.html.erb
@@ -8,8 +8,8 @@
<%= t('.scopes_label') %>
<% scope_options = %w[system proposals meetings debates pages] %>
<% scope_options.each do |scope| %>
-