diff options
author | Nick Thomas <nick@gitlab.com> | 2018-02-06 13:25:46 +0000 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2018-02-23 12:22:29 +0000 |
commit | ee68bd9771f671ce7c258a8f5441125f1a9c2d53 (patch) | |
tree | 965830e9733bf7ee60e1971c93d1c91b9d584db5 /app/controllers/projects/pages_domains_controller.rb | |
parent | 58a312f5097b30a93100de93d06427402d514b48 (diff) | |
download | gitlab-ce-ee68bd9771f671ce7c258a8f5441125f1a9c2d53.tar.gz |
Add DNS verification to Pages custom domains
Diffstat (limited to 'app/controllers/projects/pages_domains_controller.rb')
-rw-r--r-- | app/controllers/projects/pages_domains_controller.rb | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/app/controllers/projects/pages_domains_controller.rb b/app/controllers/projects/pages_domains_controller.rb index 15e77d854dc..b71f1e5fef4 100644 --- a/app/controllers/projects/pages_domains_controller.rb +++ b/app/controllers/projects/pages_domains_controller.rb @@ -3,7 +3,7 @@ class Projects::PagesDomainsController < Projects::ApplicationController before_action :require_pages_enabled! before_action :authorize_update_pages!, except: [:show] - before_action :domain, only: [:show, :destroy] + before_action :domain, only: [:show, :destroy, :verify] def show end @@ -12,11 +12,23 @@ class Projects::PagesDomainsController < Projects::ApplicationController @domain = @project.pages_domains.new end + def verify + result = VerifyPagesDomainService.new(@domain).execute + + if result[:status] == :success + flash[:notice] = 'Successfully verified domain ownership' + else + flash[:alert] = 'Failed to verify domain ownership' + end + + redirect_to project_pages_domain_path(@project, @domain) + end + def create @domain = @project.pages_domains.create(pages_domain_params) if @domain.valid? - redirect_to project_pages_path(@project) + redirect_to project_pages_domain_path(@project, @domain) else render 'new' end @@ -46,6 +58,6 @@ class Projects::PagesDomainsController < Projects::ApplicationController end def domain - @domain ||= @project.pages_domains.find_by(domain: params[:id].to_s) + @domain ||= @project.pages_domains.find_by!(domain: params[:id].to_s) end end |