Sha256: 0e5c6dca45ace4d12f3295d2cd023d6685efcf75c778e55e49074afa1a5c8f03

Contents?: true

Size: 1.39 KB

Versions: 1

Compression:

Stored size: 1.39 KB

Contents

# frozen_string_literal: true

module Decidim
  module Msad
    module Verification
      # This is an engine that performs user authorization.
      class Engine < ::Rails::Engine
        isolate_namespace Decidim::Msad::Verification

        paths["db/migrate"] = nil
        paths["lib/tasks"] = nil

        routes do
          resource :authorizations, only: [:new], as: :authorization

          root to: "authorizations#new"
        end

        initializer "decidim_msad.verification_workflow", after: :load_config_initializers do
          next unless Decidim::Msad.configured?

          # We cannot use the name `:msad` for the verification workflow
          # because otherwise the route namespace (decidim_msad) would
          # conflict with the main engine controlling the authentication flows.
          # The main problem that this would bring is that the root path for
          # this engine would not be found.
          Decidim::Verifications.register_workflow(:msad_identity) do |workflow|
            workflow.engine = Decidim::Msad::Verification::Engine

            Decidim::Msad::Verification::Manager.configure_workflow(workflow)
          end
        end

        def load_seed
          # Enable the `:msad_identity` authorization
          org = Decidim::Organization.first
          org.available_authorizations << :msad_identity
          org.save!
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
decidim-msad-0.22.0 lib/decidim/msad/verification/engine.rb