Class: Decidim::Verifications::AuthorizeUser
- Inherits:
-
Command
- Object
- Command
- Decidim::Verifications::AuthorizeUser
- Defined in:
- app/commands/decidim/verifications/authorize_user.rb
Overview
A command to authorize a user with an authorization handler.
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(handler, organization) ⇒ AuthorizeUser
constructor
Public: Initializes the command.
Constructor Details
#initialize(handler, organization) ⇒ AuthorizeUser
Public: Initializes the command.
handler - An AuthorizationHandler object.
10 11 12 13 |
# File 'app/commands/decidim/verifications/authorize_user.rb', line 10 def initialize(handler, organization) @handler = handler @organization = organization end |
Instance Method Details
#call ⇒ Object
Executes the command. Broadcasts these events:
-
:ok when everything is valid.
-
:invalid if the handler was not valid and we could not proceed.
Returns nothing.
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/commands/decidim/verifications/authorize_user.rb', line 21 def call return if !handler.unique? && handler.transferrable? if handler.invalid? register_conflict return broadcast(:invalid) end Authorization.create_or_update_from(handler) broadcast(:ok) end |