diff options
author | Rob Watson <rob@mixlr.com> | 2018-01-03 08:07:03 +0000 |
---|---|---|
committer | Rob Watson <rob@mixlr.com> | 2018-03-22 19:58:36 +0100 |
commit | 9d45951fcaeda4f01a2e4be2480d980a3e7cd37e (patch) | |
tree | 536b456729edad79ba718d987a39f235587d4dfb /app/models/pages_domain.rb | |
parent | 53d352aaf4ce7f0d2bcaf04cce5252b753ef7938 (diff) | |
download | gitlab-ce-9d45951fcaeda4f01a2e4be2480d980a3e7cd37e.tar.gz |
Add HTTPS-only pages
Closes #28857
Diffstat (limited to 'app/models/pages_domain.rb')
-rw-r--r-- | app/models/pages_domain.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/app/models/pages_domain.rb b/app/models/pages_domain.rb index 588bd50ed77..2e478a24778 100644 --- a/app/models/pages_domain.rb +++ b/app/models/pages_domain.rb @@ -6,8 +6,10 @@ class PagesDomain < ActiveRecord::Base validates :domain, hostname: { allow_numeric_hostname: true } validates :domain, uniqueness: { case_sensitive: false } - validates :certificate, certificate: true, allow_nil: true, allow_blank: true - validates :key, certificate_key: true, allow_nil: true, allow_blank: true + validates :certificate, presence: { message: 'must be present if HTTPS-only is enabled' }, if: ->(domain) { domain.project&.pages_https_only? } + validates :certificate, certificate: true, if: ->(domain) { domain.certificate.present? } + validates :key, presence: { message: 'must be present if HTTPS-only is enabled' }, if: ->(domain) { domain.project&.pages_https_only? } + validates :key, certificate_key: true, if: ->(domain) { domain.key.present? } validates :verification_code, presence: true, allow_blank: false validate :validate_pages_domain @@ -46,6 +48,10 @@ class PagesDomain < ActiveRecord::Base !Gitlab::CurrentSettings.pages_domain_verification_enabled? || enabled_until.present? end + def https? + certificate.present? + end + def to_param domain end |