Sha256: 58d003e5171903c9e2ace7b03730c15ea01f31bbd914eb512eb9dfb38efb08f2

Contents?: true

Size: 1.03 KB

Versions: 14

Compression:

Stored size: 1.03 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, :organization_logo, presence: true
      validates :organization_logo, passthru: { to: Decidim::OAuthApplication }
      validate :redirect_uri_is_ssl

      alias organization current_organization

      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

14 entries across 14 versions & 1 rubygems

Version Path
decidim-system-0.24.3 app/forms/decidim/system/oauth_application_form.rb
decidim-system-0.23.6 app/forms/decidim/system/oauth_application_form.rb
decidim-system-0.24.2 app/forms/decidim/system/oauth_application_form.rb
decidim-system-0.23.5 app/forms/decidim/system/oauth_application_form.rb
decidim-system-0.24.1 app/forms/decidim/system/oauth_application_form.rb
decidim-system-0.24.0 app/forms/decidim/system/oauth_application_form.rb
decidim-system-0.24.0.rc2 app/forms/decidim/system/oauth_application_form.rb
decidim-system-0.23.4 app/forms/decidim/system/oauth_application_form.rb
decidim-system-0.24.0.rc1 app/forms/decidim/system/oauth_application_form.rb
decidim-system-0.23.3 app/forms/decidim/system/oauth_application_form.rb
decidim-system-0.23.2 app/forms/decidim/system/oauth_application_form.rb
decidim-system-0.23.1 app/forms/decidim/system/oauth_application_form.rb
decidim-system-0.23.1.rc1 app/forms/decidim/system/oauth_application_form.rb
decidim-system-0.23.0 app/forms/decidim/system/oauth_application_form.rb