diff options
Diffstat (limited to 'app/models/pages_domain.rb')
-rw-r--r-- | app/models/pages_domain.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/app/models/pages_domain.rb b/app/models/pages_domain.rb index 2e25839c47f..16d5492a65e 100644 --- a/app/models/pages_domain.rb +++ b/app/models/pages_domain.rb @@ -33,6 +33,7 @@ class PagesDomain < ApplicationRecord validate :validate_pages_domain validate :validate_matching_key, if: ->(domain) { domain.certificate.present? || domain.key.present? } validate :validate_intermediates, if: ->(domain) { domain.certificate.present? && domain.certificate_changed? } + validate :validate_custom_domain_count_per_project, on: :create default_value_for(:auto_ssl_enabled, allows_nil: false) { ::Gitlab::LetsEncrypt.enabled? } default_value_for :scope, allows_nil: false, value: :project @@ -57,6 +58,7 @@ class PagesDomain < ApplicationRecord where(verified_at.eq(nil).or(enabled_until.eq(nil).or(enabled_until.lt(threshold)))) end + scope :verified, -> { where.not(verified_at: nil) } scope :need_auto_ssl_renewal, -> do enabled_and_not_failed = where(auto_ssl_enabled: true, auto_ssl_failed: false) @@ -224,6 +226,16 @@ class PagesDomain < ApplicationRecord self.auto_ssl_failed = false end + def validate_custom_domain_count_per_project + return unless project + + unless project.can_create_custom_domains? + self.errors.add( + :base, + _("This project reached the limit of custom domains. (Max %d)") % Gitlab::CurrentSettings.max_pages_custom_domains_per_project) + end + end + private def pages_deployed? |