mirror of
				https://github.com/lingble/chatwoot.git
				synced 2025-10-30 18:47:51 +00:00 
			
		
		
		
	 bd97226c95
			
		
	
	bd97226c95
	
	
	
		
			
			- Ensuring that SwitchLocale concern handles the case of custom domain for portals and set locale according to that Co-authored-by: Sojan Jose <sojan@pepalo.com>
		
			
				
	
	
		
			22 lines
		
	
	
		
			724 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			22 lines
		
	
	
		
			724 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
| # 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
 | |
| class PublicController < ActionController::Base
 | |
|   include RequestExceptionHandler
 | |
|   skip_before_action :verify_authenticity_token
 | |
| 
 | |
|   private
 | |
| 
 | |
|   def ensure_custom_domain_request
 | |
|     domain = request.host
 | |
|     return if DomainHelper.chatwoot_domain?(domain)
 | |
| 
 | |
|     @portal = ::Portal.find_by(custom_domain: domain)
 | |
|     return if @portal.present?
 | |
| 
 | |
|     render json: {
 | |
|       error: "Domain: #{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
 | |
| end
 |