summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorVladimir Shushlin <v.shushlin@gmail.com>2019-07-12 17:19:01 +0300
committerVladimir Shushlin <v.shushlin@gmail.com>2019-07-12 17:19:01 +0300
commit12563bb37c3b439f1bf12b2fe66fb2034bfc24a0 (patch)
tree4dfe07056080cb77d27a502c0e7e6f5c60ea39be /app
parent5ea899d34f6332733bb5aee225c5f3ced340cb24 (diff)
downloadgitlab-ce-12563bb37c3b439f1bf12b2fe66fb2034bfc24a0.tar.gz
Fix saving domain without certificate for auto_sslfix-only-https-pages-domains
Diffstat (limited to 'app')
-rw-r--r--app/models/pages_domain.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/app/models/pages_domain.rb b/app/models/pages_domain.rb
index d6d879c6d89..e6e491634ab 100644
--- a/app/models/pages_domain.rb
+++ b/app/models/pages_domain.rb
@@ -12,9 +12,11 @@ class PagesDomain < ApplicationRecord
validates :domain, hostname: { allow_numeric_hostname: true }
validates :domain, uniqueness: { case_sensitive: false }
- validates :certificate, presence: { message: 'must be present if HTTPS-only is enabled' }, if: ->(domain) { domain.project&.pages_https_only? }
+ validates :certificate, presence: { message: 'must be present if HTTPS-only is enabled' },
+ if: :certificate_should_be_present?
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, presence: { message: 'must be present if HTTPS-only is enabled' },
+ if: :certificate_should_be_present?
validates :key, certificate_key: true, if: ->(domain) { domain.key.present? }
validates :verification_code, presence: true, allow_blank: false
@@ -249,4 +251,8 @@ class PagesDomain < ApplicationRecord
rescue OpenSSL::PKey::PKeyError, OpenSSL::Cipher::CipherError
nil
end
+
+ def certificate_should_be_present?
+ !auto_ssl_enabled? && project&.pages_https_only?
+ end
end