Sha256: 3963a94b6bd308ca16ea79e4b99ab580ddc475a7cff0b95921ddaebc51067088
Contents?: true
Size: 1.35 KB
Versions: 19
Compression:
Stored size: 1.35 KB
Contents
# frozen_string_literal: true module Decidim module System # Creates an OAuthApplication. class CreateOAuthApplication < Rectify::Command # Initializes the command. # # form - The source fo data for this OAuthApplication. def initialize(form) @form = form end def call return broadcast(:invalid) unless @form.valid? @application = Decidim.traceability.create!( OAuthApplication, @form.current_user, **oauth_application_attributes ) broadcast(:ok, @application) rescue ActiveRecord::RecordInvalid @form.errors.add(:organization_logo, @application.errors[:organization_logo]) if @application.errors.include? :organization_logo broadcast(:invalid) end def oauth_application_attributes { 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.organization_logo, redirect_uri: @form.redirect_uri, scopes: "public" }.tap do |attrs| attrs[:organization_logo] = @form.organization_logo if @form.organization_logo.present? end end end end end
Version data entries
19 entries across 19 versions & 1 rubygems