mirror of
https://github.com/astuto/astuto.git
synced 2025-12-15 19:27:52 +01:00
Add custom domains (#314)
This commit is contained in:
committed by
GitHub
parent
d47c70f576
commit
d17b45c5c4
@@ -1,3 +1,5 @@
|
||||
require 'httparty'
|
||||
|
||||
class TenantsController < ApplicationController
|
||||
include ApplicationHelper
|
||||
|
||||
@@ -66,6 +68,23 @@ class TenantsController < ApplicationController
|
||||
@tenant = Current.tenant_or_raise!
|
||||
authorize @tenant
|
||||
|
||||
# If the custom domain has changed, we need to provision SSL certificate
|
||||
custom_domain_response = AddCustomDomainWorkflow.new(
|
||||
new_custom_domain: params[:tenant][:custom_domain],
|
||||
current_custom_domain: @tenant.custom_domain
|
||||
).run
|
||||
|
||||
if custom_domain_response == false
|
||||
render json: {
|
||||
error: "Error adding custom domain"
|
||||
}, status: :unprocessable_entity
|
||||
return
|
||||
end
|
||||
|
||||
# Since custom_domain is unique at db level, we need to set it to nil if it is blank
|
||||
# to avoid unique constraint violation
|
||||
params[:tenant][:custom_domain] = nil if params[:tenant][:custom_domain].blank?
|
||||
|
||||
if @tenant.update(tenant_update_params)
|
||||
render json: @tenant
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user