Class: Decidim::System::CreateOAuthApplication

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

Overview

Creates an OAuthApplication.

Instance Method Summary collapse

Constructor Details

#initialize(form) ⇒ CreateOAuthApplication

Initializes the command.

form - The source fo data for this OAuthApplication.


10
11
12
# File 'decidim-system/app/commands/decidim/system/create_oauth_application.rb', line 10

def initialize(form)
  @form = form
end

Instance Method Details

#callObject


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'decidim-system/app/commands/decidim/system/create_oauth_application.rb', line 14

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

  @application = Decidim.traceability.create!(
    OAuthApplication,
    @form.current_user,
    organization: @form.current_organization,
    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,
    scopes: "public"
  )

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