Class: Decidim::AccessRequests::Verification::Admin::PendingAuthorizationsController

Inherits:
Decidim::Admin::ApplicationController
  • Object
show all
Includes:
DetectableVerificationManifest
Defined in:
app/controllers/decidim/access_requests/verification/admin/pending_authorizations_controller.rb

Instance Method Summary collapse

Methods included from DetectableVerificationManifest

#verification_manifest, #verification_manifest_handle

Instance Method Details

#destroyObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/controllers/decidim/access_requests/verification/admin/pending_authorizations_controller.rb', line 38

def destroy
  enforce_permission_to :destroy, :authorization, authorization: authorization

  DestroyAuthorization.call(authorization) do
    on(:ok) do
      flash[:notice] = t("pending_authorizations.destroy.success", scope: "decidim.access_requests.verification.admin")
      redirect_to pending_authorizations_path
    end

    on(:invalid) do
      flash.now[:alert] = t("pending_authorizations.destroy.error", scope: "decidim.access_requests.verification.admin")
      redirect_to pending_authorizations_path
    end
  end
end

#indexObject



12
13
14
15
16
# File 'app/controllers/decidim/access_requests/verification/admin/pending_authorizations_controller.rb', line 12

def index
  enforce_permission_to :index, :authorization

  @pending_authorizations = pending_authorizations
end

#updateObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/decidim/access_requests/verification/admin/pending_authorizations_controller.rb', line 18

def update
  enforce_permission_to :edit, :authorization, authorization: authorization

  @form = RequestForm.new(
    handler_handle: verification_manifest.name
  ).with_context(current_organization: current_organization)

  ConfirmUserAccessRequest.call(authorization, @form) do
    on(:ok) do
      flash[:notice] = t("pending_authorizations.update.success", scope: "decidim.access_requests.verification.admin")
      redirect_to pending_authorizations_path
    end

    on(:invalid) do
      flash.now[:alert] = t("pending_authorizations.update.error", scope: "decidim.access_requests.verification.admin")
      redirect_to pending_authorizations_path
    end
  end
end