Class: Decidim::AccessRequests::Verification::AuthorizationsController

Inherits:
Decidim::ApplicationController
  • Object
show all
Defined in:
app/controllers/decidim/access_requests/verification/authorizations_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  enforce_permission_to :create, :authorization, authorization: @authorization

  @form = RequestForm.from_params(
    params.merge(user: current_user)
  ).with_context(current_organization: current_organization)

  Decidim::Verifications::PerformAuthorizationStep.call(@authorization, @form) do
    on(:ok) do
      flash[:notice] = t("authorizations.create.success", scope: "decidim.access_requests.verification")
      redirect_to decidim_verifications.authorizations_path
    end

    on(:invalid) do
      flash.now[:alert] = t("authorizations.create.error", scope: "decidim.access_requests.verification")
      render :new
    end
  end
end

#editObject



37
38
39
# File 'app/controllers/decidim/access_requests/verification/authorizations_controller.rb', line 37

def edit
  enforce_permission_to :create, :authorization, authorization: @authorization
end

#newObject



11
12
13
14
15
# File 'app/controllers/decidim/access_requests/verification/authorizations_controller.rb', line 11

def new
  enforce_permission_to :create, :authorization, authorization: @authorization

  @form = RequestForm.new(handler_handle: authorization_handle)
end