2017-08-17 22:00:37 +05:30
|
|
|
class Projects::PagesDomainsController < Projects::ApplicationController
|
|
|
|
layout 'project_settings'
|
|
|
|
|
|
|
|
before_action :require_pages_enabled!
|
|
|
|
before_action :authorize_update_pages!, except: [:show]
|
2018-03-27 19:54:05 +05:30
|
|
|
before_action :domain, except: [:new, :create]
|
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
|
|
|
|
|
|
|
|
redirect_to project_pages_domain_path(@project, @domain)
|
|
|
|
end
|
|
|
|
|
2018-03-27 19:54:05 +05:30
|
|
|
def edit
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
def create
|
2018-03-27 19:54:05 +05:30
|
|
|
@domain = @project.pages_domains.create(create_params)
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
if @domain.valid?
|
2018-03-17 18:26:18 +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
|
|
|
|
if @domain.update(update_params)
|
|
|
|
redirect_to project_pages_path(@project),
|
|
|
|
status: 302,
|
|
|
|
notice: 'Domain was updated'
|
|
|
|
else
|
|
|
|
render 'edit'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
def destroy
|
|
|
|
@domain.destroy
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html do
|
2017-09-10 17:25:29 +05:30
|
|
|
redirect_to project_pages_path(@project),
|
|
|
|
status: 302,
|
|
|
|
notice: 'Domain was removed'
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
format.js
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2018-03-27 19:54:05 +05:30
|
|
|
def create_params
|
|
|
|
params.require(:pages_domain).permit(:key, :certificate, :domain)
|
|
|
|
end
|
|
|
|
|
|
|
|
def update_params
|
|
|
|
params.require(:pages_domain).permit(:key, :certificate)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def domain
|
2018-03-17 18:26:18 +05:30
|
|
|
@domain ||= @project.pages_domains.find_by!(domain: params[:id].to_s)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|