Sha256: 4af003df9b395e8dd8d322119e574f26339a7fa873933448081df9827aee0c41

Contents?: true

Size: 775 Bytes

Versions: 38

Compression:

Stored size: 775 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Verifications
    # A command to authorize a user with an authorization handler.
    class AuthorizeUser < Rectify::Command
      # Public: Initializes the command.
      #
      # handler - An AuthorizationHandler object.
      def initialize(handler)
        @handler = handler
      end

      # Executes the command. Broadcasts these events:
      #
      # - :ok when everything is valid.
      # - :invalid if the handler wasn't valid and we couldn't proceed.
      #
      # Returns nothing.
      def call
        return broadcast(:invalid) unless handler.valid?

        Authorization.create_or_update_from(handler)

        broadcast(:ok)
      end

      private

      attr_reader :handler
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
decidim-verifications-0.23.6 app/commands/decidim/verifications/authorize_user.rb
decidim-verifications-0.23.5 app/commands/decidim/verifications/authorize_user.rb
decidim-verifications-0.23.4 app/commands/decidim/verifications/authorize_user.rb
decidim-verifications-0.23.3 app/commands/decidim/verifications/authorize_user.rb
decidim-verifications-0.23.2 app/commands/decidim/verifications/authorize_user.rb
decidim-verifications-0.23.1 app/commands/decidim/verifications/authorize_user.rb
decidim-verifications-0.23.1.rc1 app/commands/decidim/verifications/authorize_user.rb
decidim-verifications-0.23.0 app/commands/decidim/verifications/authorize_user.rb
decidim-verifications-0.22.0 app/commands/decidim/verifications/authorize_user.rb
decidim-verifications-0.21.0 app/commands/decidim/verifications/authorize_user.rb
decidim-verifications-0.20.1 app/commands/decidim/verifications/authorize_user.rb
decidim-verifications-0.20.0 app/commands/decidim/verifications/authorize_user.rb
decidim-verifications-0.19.1 app/commands/decidim/verifications/authorize_user.rb
decidim-verifications-0.18.1 app/commands/decidim/verifications/authorize_user.rb
decidim-verifications-0.19.0 app/commands/decidim/verifications/authorize_user.rb
decidim-verifications-0.17.2 app/commands/decidim/verifications/authorize_user.rb
decidim-verifications-0.18.0 app/commands/decidim/verifications/authorize_user.rb
decidim-verifications-0.17.1 app/commands/decidim/verifications/authorize_user.rb
decidim-verifications-0.16.1 app/commands/decidim/verifications/authorize_user.rb
decidim-verifications-0.17.0 app/commands/decidim/verifications/authorize_user.rb