2021-07-14 13:10:24 +00:00
|
|
|
# TODO: we should switch to ActionController::API for the base classes
|
|
|
|
# One of the specs is failing when I tried doing that, lets revisit in future
|
2021-06-15 14:39:17 +00:00
|
|
|
class PublicController < ActionController::Base
|
2021-09-14 06:25:02 +00:00
|
|
|
include RequestExceptionHandler
|
2021-06-15 14:39:17 +00:00
|
|
|
skip_before_action :verify_authenticity_token
|
2022-09-07 06:52:24 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def ensure_custom_domain_request
|
|
|
|
custom_domain = request.host
|
|
|
|
|
|
|
|
@portals = ::Portal.where(custom_domain: custom_domain)
|
|
|
|
|
|
|
|
return if @portals.present?
|
|
|
|
|
|
|
|
render json: {
|
|
|
|
error: "Domain: #{custom_domain} is not registered with us. \
|
|
|
|
Please send us an email at support@chatwoot.com with the custom domain name and account API key"
|
|
|
|
}, status: :unauthorized and return
|
|
|
|
end
|
2021-06-15 14:39:17 +00:00
|
|
|
end
|