Class: Decidim::Toggle::UpdateSecurityCommand
- Inherits:
-
Command
- Object
- Command
- Decidim::Toggle::UpdateSecurityCommand
- Defined in:
- app/commands/decidim/toggle/update_security_command.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(organization, form) ⇒ UpdateSecurityCommand
constructor
A new instance of UpdateSecurityCommand.
Constructor Details
#initialize(organization, form) ⇒ UpdateSecurityCommand
Returns a new instance of UpdateSecurityCommand.
6 7 8 9 |
# File 'app/commands/decidim/toggle/update_security_command.rb', line 6 def initialize(organization, form) @organization = organization @form = form end |
Instance Method Details
#call ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/commands/decidim/toggle/update_security_command.rb', line 11 def call return broadcast(:invalid) if form.invalid? transaction do organization.force_users_to_authenticate_before_access_organization = form.force_users_to_authenticate_before_access_organization organization.users_registration_mode = form.users_registration_mode organization.content_security_policy = form.content_security_policy organization.save! end broadcast(:ok) rescue ActiveRecord::RecordInvalid broadcast(:invalid) end |