Class: Decidim::System::UpdateOAuthApplication

Inherits:
Rectify::Command
  • Object
show all
Defined in:
decidim-system/app/commands/decidim/system/update_oauth_application.rb

Overview

Updates the OAuth application given form data.

Instance Method Summary collapse

Constructor Details

#initialize(application, form, user) ⇒ UpdateOAuthApplication

Initializes the command.

application - The OAuthApplication to update. form - The form object containing the data to update. user - The user that updates the application.


12
13
14
15
16
# File 'decidim-system/app/commands/decidim/system/update_oauth_application.rb', line 12

def initialize(application, form, user)
  @application = application
  @form = form
  @user = user
end

Instance Method Details

#callObject


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'decidim-system/app/commands/decidim/system/update_oauth_application.rb', line 18

def call
  return broadcast(:invalid) unless @form.valid?

  @application = Decidim.traceability.update!(
    @application,
    @user,
    name: @form.name,
    decidim_organization_id: @form.decidim_organization_id,
    organization_name: @form.organization_name,
    organization_url: @form.organization_url,
    organization_logo: @form.,
    redirect_uri: @form.redirect_uri
  )

  broadcast(:ok, @application)
rescue ActiveRecord::RecordInvalid
  @form.errors.add(:organization_logo, @application.errors[:organization_logo]) if @application.errors.include? :organization_logo
  broadcast(:invalid)
end