Sha256: 7a3eb2402aa0ae7e30db7934d627e28662b91803c1686a2fcd35775b6b694c05

Contents?: true

Size: 1.22 KB

Versions: 44

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

module Decidim
  module System
    # The form that validates the data to construct a valid OAuthApplication.
    class OAuthApplicationForm < Decidim::Form
      include Decidim::HasUploadValidations

      mimic :oauth_application

      attribute :name, String
      attribute :decidim_organization_id, Integer
      attribute :organization_name, String
      attribute :organization_url, String
      attribute :organization_logo
      attribute :redirect_uri, String

      validates :name, :redirect_uri, :decidim_organization_id, :organization_name, :organization_url, presence: true
      validates :redirect_uri, :organization_url, url: true
      validates :organization_logo, presence: true, unless: :persisted?
      validates :organization_logo, passthru: { to: Decidim::OAuthApplication }
      validate :redirect_uri_is_ssl

      def organization
        current_organization || Decidim::Organization.find_by(id: decidim_organization_id)
      end

      private

      def redirect_uri_is_ssl
        return if redirect_uri.blank?

        uri = URI.parse(redirect_uri)

        errors.add(:redirect_uri, :must_be_ssl) if uri.host != "localhost" && uri.scheme != "https"
      end
    end
  end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
decidim-system-0.29.1 app/forms/decidim/system/oauth_application_form.rb
decidim-system-0.28.4 app/forms/decidim/system/oauth_application_form.rb
decidim-system-0.27.9 app/forms/decidim/system/oauth_application_form.rb
decidim-system-0.29.0 app/forms/decidim/system/oauth_application_form.rb
decidim-system-0.28.3 app/forms/decidim/system/oauth_application_form.rb
decidim-system-0.27.8 app/forms/decidim/system/oauth_application_form.rb
decidim-system-0.29.0.rc4 app/forms/decidim/system/oauth_application_form.rb
decidim-system-0.29.0.rc3 app/forms/decidim/system/oauth_application_form.rb
decidim-system-0.29.0.rc2 app/forms/decidim/system/oauth_application_form.rb
decidim-system-0.29.0.rc1 app/forms/decidim/system/oauth_application_form.rb
decidim-system-0.28.2 app/forms/decidim/system/oauth_application_form.rb
decidim-system-0.27.7 app/forms/decidim/system/oauth_application_form.rb
decidim-system-0.28.1 app/forms/decidim/system/oauth_application_form.rb
decidim-system-0.27.6 app/forms/decidim/system/oauth_application_form.rb
decidim-system-0.26.10 app/forms/decidim/system/oauth_application_form.rb
decidim-system-0.26.9 app/forms/decidim/system/oauth_application_form.rb
decidim-system-0.28.0 app/forms/decidim/system/oauth_application_form.rb
decidim-system-0.27.5 app/forms/decidim/system/oauth_application_form.rb
decidim-system-0.28.0.rc5 app/forms/decidim/system/oauth_application_form.rb
decidim-system-0.28.0.rc4 app/forms/decidim/system/oauth_application_form.rb