Sha256: b1cf3ef15fd2fa2ed14d468b3cbd1acc55327b56ec676e4eda52be1fb40eaf5f

Contents?: true

Size: 820 Bytes

Versions: 6

Compression:

Stored size: 820 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Admin
    class ShareTokensController < Decidim::Admin::ApplicationController
      def destroy
        enforce_permission_to(:destroy, :share_token, share_token:)

        Decidim::Commands::DestroyResource.call(share_token, current_user) do
          on(:ok) do
            flash[:notice] = I18n.t("share_tokens.destroy.success", scope: "decidim.admin")
          end
          on(:invalid) do
            flash[:error] = I18n.t("share_tokens.destroy.error", scope: "decidim.admin")
          end
        end

        redirect_back(fallback_location: root_path)
      end

      private

      def share_token
        @share_token ||= Decidim::ShareToken.where(
          organization: current_organization
        ).find(params[:id])
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
decidim-admin-0.29.1 app/controllers/decidim/admin/share_tokens_controller.rb
decidim-admin-0.29.0 app/controllers/decidim/admin/share_tokens_controller.rb
decidim-admin-0.29.0.rc4 app/controllers/decidim/admin/share_tokens_controller.rb
decidim-admin-0.29.0.rc3 app/controllers/decidim/admin/share_tokens_controller.rb
decidim-admin-0.29.0.rc2 app/controllers/decidim/admin/share_tokens_controller.rb
decidim-admin-0.29.0.rc1 app/controllers/decidim/admin/share_tokens_controller.rb