Sha256: 08f92d9f7711c546f5046afa8b14662a76aede4681d1c0b05a4908cb5e330c1c
Contents?: true
Size: 855 Bytes
Versions: 1
Compression:
Stored size: 855 Bytes
Contents
# frozen_string_literal: true module Decidim # 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.authorized? create_authorization broadcast(:ok) end private attr_reader :handler def create_authorization Authorization.create!( user: handler.user, name: handler.handler_name, metadata: handler.metadata ) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
decidim-core-0.0.1 | app/commands/decidim/authorize_user.rb |