diff options
author | Vladimir Shushlin <v.shushlin@gmail.com> | 2019-03-22 20:35:40 +0300 |
---|---|---|
committer | Vladimir Shushlin <v.shushlin@gmail.com> | 2019-04-09 13:48:32 +0300 |
commit | 291684912af45f9a83d5a65676cdbcbc617353be (patch) | |
tree | 36904d9dbcc36e9c3897bb91fb15ed79d9708132 | |
parent | 156ce409e5db854654e99dab68f762118fc86c90 (diff) | |
download | gitlab-ce-291684912af45f9a83d5a65676cdbcbc617353be.tar.gz |
Remove ssl certs when user changes pages auto_ssl
-rw-r--r-- | app/models/pages_domain.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/app/models/pages_domain.rb b/app/models/pages_domain.rb index 82901ceec01..391ebacb2d6 100644 --- a/app/models/pages_domain.rb +++ b/app/models/pages_domain.rb @@ -6,6 +6,8 @@ class PagesDomain < ApplicationRecord belongs_to :project + before_validation :cleanup_ssl_cert, if: -> { auto_ssl_enabled_changed? } + 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? } @@ -198,4 +200,9 @@ class PagesDomain < ApplicationRecord rescue OpenSSL::PKey::PKeyError, OpenSSL::Cipher::CipherError nil end + + def cleanup_ssl_cert + self.certificate = nil + self.key = nil + end end |