Sha256: c29945b2e0a64f92481aac07b0b41b2a321e1eba2108283fc65e879ba6d55c57

Contents?: true

Size: 1.41 KB

Versions: 3

Compression:

Stored size: 1.41 KB

Contents

# frozen_string_literal: true

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

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

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

          root to: "authorizations#new"
        end

        initializer "decidim_suomifi.verification_workflow", after: :load_config_initializers do
          next unless Decidim::Suomifi.configured?

          # We cannot use the name `:suomifi` for the verification workflow
          # because otherwise the route namespace (decidim_suomifi) 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(:suomifi_eid) do |workflow|
            workflow.engine = Decidim::Suomifi::Verification::Engine

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
decidim-suomifi-0.19.0 lib/decidim/suomifi/verification/engine.rb
decidim-suomifi-0.18.1 lib/decidim/suomifi/verification/engine.rb
decidim-suomifi-0.18.0 lib/decidim/suomifi/verification/engine.rb