Sha256: 362663c20c9ddbed1bd8aff034aa6e9503b1b07b43f0bb31b9a22a7027cc2ca5
Contents?: true
Size: 1.42 KB
Versions: 19
Compression:
Stored size: 1.42 KB
Contents
# frozen_string_literal: true module Decidim module System # Updates the OAuth application given form data. class UpdateOAuthApplication < Rectify::Command # Initializes the command. # # application - The OAuthApplication to update. # form - The form object containing the data to update. # user - The user that updates the application. def initialize(application, form, user) @application = application @form = form @user = user end def call return broadcast(:invalid) unless @form.valid? @application = Decidim.traceability.update!( @application, @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 { name: @form.name, decidim_organization_id: @form.decidim_organization_id, organization_name: @form.organization_name, organization_url: @form.organization_url, redirect_uri: @form.redirect_uri }.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