debian-mirror-gitlab/app/controllers/projects/pages_domains_controller.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

105 lines
2.5 KiB
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
class Projects::PagesDomainsController < Projects::ApplicationController
layout 'project_settings'
before_action :require_pages_enabled!
2019-07-07 11:18:12 +05:30
before_action :authorize_update_pages!
2018-03-27 19:54:05 +05:30
before_action :domain, except: [:new, :create]
2017-08-17 22:00:37 +05:30
2020-05-24 23:13:21 +05:30
helper_method :domain_presenter
2021-01-03 14:25:43 +05:30
feature_category :pages
2017-08-17 22:00:37 +05:30
def show
end
def new
@domain = @project.pages_domains.new
end
2018-03-17 18:26:18 +05:30
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
2020-01-01 13:55:28 +05:30
redirect_to project_pages_domain_path(@project, @domain)
2018-03-17 18:26:18 +05:30
end
2020-04-22 19:07:51 +05:30
def retry_auto_ssl
2020-05-24 23:13:21 +05:30
PagesDomains::RetryAcmeOrderService.new(@domain).execute
2020-04-22 19:07:51 +05:30
redirect_to project_pages_domain_path(@project, @domain)
end
2018-03-27 19:54:05 +05:30
def edit
2020-01-01 13:55:28 +05:30
redirect_to project_pages_domain_path(@project, @domain)
2018-03-27 19:54:05 +05:30
end
2017-08-17 22:00:37 +05:30
def create
2022-11-25 23:54:43 +05:30
@domain = PagesDomains::CreateService.new(@project, current_user, create_params).execute
2017-08-17 22:00:37 +05:30
2022-11-25 23:54:43 +05:30
if @domain&.persisted?
2020-01-01 13:55:28 +05:30
redirect_to project_pages_domain_path(@project, @domain)
2017-08-17 22:00:37 +05:30
else
render 'new'
end
end
2018-03-27 19:54:05 +05:30
def update
2022-11-25 23:54:43 +05:30
service = ::PagesDomains::UpdateService.new(@project, current_user, update_params)
if service.execute(@domain)
2018-03-27 19:54:05 +05:30
redirect_to project_pages_path(@project),
2019-12-26 22:10:19 +05:30
status: :found,
2018-03-27 19:54:05 +05:30
notice: 'Domain was updated'
else
2020-01-01 13:55:28 +05:30
render 'show'
2018-03-27 19:54:05 +05:30
end
end
2017-08-17 22:00:37 +05:30
def destroy
2022-11-25 23:54:43 +05:30
PagesDomains::DeleteService
.new(@project, current_user)
.execute(@domain)
2017-08-17 22:00:37 +05:30
respond_to do |format|
format.html do
2023-05-27 22:25:52 +05:30
redirect_to project_pages_path(@project), status: :found, notice: 'Domain was removed'
2017-08-17 22:00:37 +05:30
end
format.js
end
end
2019-12-26 22:10:19 +05:30
def clean_certificate
2022-11-25 23:54:43 +05:30
update_params = { user_provided_certificate: nil, user_provided_key: nil }
service = ::PagesDomains::UpdateService.new(@project, current_user, update_params)
flash[:alert] = @domain.errors.full_messages.join(', ') unless service.execute(@domain)
2019-12-26 22:10:19 +05:30
2020-01-01 13:55:28 +05:30
redirect_to project_pages_domain_path(@project, @domain)
2019-12-26 22:10:19 +05:30
end
2017-08-17 22:00:37 +05:30
private
2018-03-27 19:54:05 +05:30
def create_params
2019-09-30 21:07:59 +05:30
params.require(:pages_domain).permit(:user_provided_key, :user_provided_certificate, :domain, :auto_ssl_enabled)
2018-03-27 19:54:05 +05:30
end
def update_params
2019-12-26 22:10:19 +05:30
params.fetch(:pages_domain, {}).permit(:user_provided_key, :user_provided_certificate, :auto_ssl_enabled)
2017-08-17 22:00:37 +05:30
end
def domain
2020-05-24 23:13:21 +05:30
@domain ||= @project.pages_domains.find_by_domain!(params[:id].to_s)
end
def domain_presenter
@domain_presenter ||= domain.present(current_user: current_user)
2017-08-17 22:00:37 +05:30
end
end