Sha256: 44b65ef7f8b748ff14f6c4ea26a762fd3552f2c857bbbfb1f413be1b9b9f26ea

Contents?: true

Size: 1.03 KB

Versions: 30

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

module Decidim
  module Admin
    # The form that validates the data to construct a valid OAuthApplication.
    class OAuthApplicationForm < Decidim::Form
      mimic :oauth_application

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

      validates :name, :redirect_uri, :current_user, :current_organization, :organization_name, :organization_url, :organization_logo, presence: true
      validates :organization_logo,
                file_size: { less_than_or_equal_to: ->(_record) { Decidim.maximum_attachment_size } },
                file_content_type: { allow: ["image/jpeg", "image/png"] }
      validate :redirect_uri_is_ssl

      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

30 entries across 30 versions & 1 rubygems

Version Path
decidim-admin-0.22.0 app/forms/decidim/admin/oauth_application_form.rb
decidim-admin-0.21.0 app/forms/decidim/admin/oauth_application_form.rb
decidim-admin-0.20.1 app/forms/decidim/admin/oauth_application_form.rb
decidim-admin-0.20.0 app/forms/decidim/admin/oauth_application_form.rb
decidim-admin-0.19.1 app/forms/decidim/admin/oauth_application_form.rb
decidim-admin-0.18.1 app/forms/decidim/admin/oauth_application_form.rb
decidim-admin-0.19.0 app/forms/decidim/admin/oauth_application_form.rb
decidim-admin-0.17.2 app/forms/decidim/admin/oauth_application_form.rb
decidim-admin-0.18.0 app/forms/decidim/admin/oauth_application_form.rb
decidim-admin-0.17.1 app/forms/decidim/admin/oauth_application_form.rb
decidim-admin-0.16.1 app/forms/decidim/admin/oauth_application_form.rb
decidim-admin-0.17.0 app/forms/decidim/admin/oauth_application_form.rb
decidim-admin-0.16.0 app/forms/decidim/admin/oauth_application_form.rb
decidim-admin-0.15.2 app/forms/decidim/admin/oauth_application_form.rb
decidim-admin-0.15.1 app/forms/decidim/admin/oauth_application_form.rb
decidim-admin-0.15.0 app/forms/decidim/admin/oauth_application_form.rb
decidim-admin-0.14.4 app/forms/decidim/admin/oauth_application_form.rb
decidim-admin-0.14.3 app/forms/decidim/admin/oauth_application_form.rb
decidim-admin-0.14.2 app/forms/decidim/admin/oauth_application_form.rb
decidim-admin-0.14.1 app/forms/decidim/admin/oauth_application_form.rb