Class: Decidim::Verifications::IdDocuments::AuthorizationsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Decidim::Verifications::IdDocuments::AuthorizationsController
- Includes:
- Renewable
- Defined in:
- app/controllers/decidim/verifications/id_documents/authorizations_controller.rb
Overview
Handles verification by identity document upload
Instance Method Summary collapse
Methods inherited from ApplicationController
Instance Method Details
#choose ⇒ Object
16 17 18 19 20 |
# File 'app/controllers/decidim/verifications/id_documents/authorizations_controller.rb', line 16 def choose return redirect_to action: :new, using: verification_type if available_methods.count == 1 render :choose end |
#create ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/controllers/decidim/verifications/id_documents/authorizations_controller.rb', line 30 def create :create, :authorization, authorization: @authorization @form = UploadForm.from_params(params.merge(user: current_user)).with_context(current_organization:) PerformAuthorizationStep.call(@authorization, @form) do on(:ok) do flash[:notice] = t("authorizations.create.success", scope: "decidim.verifications.id_documents") redirect_to decidim_verifications. end on(:invalid) do flash.now[:alert] = t("authorizations.create.error", scope: "decidim.verifications.id_documents") render action: :new end end end |
#edit ⇒ Object
48 49 50 51 52 |
# File 'app/controllers/decidim/verifications/id_documents/authorizations_controller.rb', line 48 def edit :update, :authorization, authorization: @authorization @form = UploadForm.from_model(@authorization) end |
#new ⇒ Object
22 23 24 25 26 27 28 |
# File 'app/controllers/decidim/verifications/id_documents/authorizations_controller.rb', line 22 def new raise ActionController::RoutingError, "Method not available" unless available_methods.include?(verification_type) :create, :authorization, authorization: @authorization @form = UploadForm.from_params(id_document_upload: { verification_type: }) end |
#update ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'app/controllers/decidim/verifications/id_documents/authorizations_controller.rb', line 54 def update :update, :authorization, authorization: @authorization @form = UploadForm.from_params( params.merge( user: current_user, verification_type:, verification_attachment: params[:id_document_upload][:verification_attachment] || @authorization..blob ) ).with_context(current_organization:) PerformAuthorizationStep.call(@authorization, @form) do on(:ok) do flash[:notice] = t("authorizations.update.success", scope: "decidim.verifications.id_documents") redirect_to decidim_verifications. end on(:invalid) do flash.now[:alert] = t("authorizations.update.error", scope: "decidim.verifications.id_documents") render action: :edit end end end |