Add custom domains (#314)

This commit is contained in:
Riccardo Graziosi
2024-03-24 12:54:02 +01:00
committed by GitHub
parent d47c70f576
commit d17b45c5c4
31 changed files with 221 additions and 39 deletions

View File

@@ -1,4 +1,7 @@
require 'uri'
class ApplicationController < ActionController::Base
include ApplicationHelper
include Pundit::Authorization
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
@@ -16,24 +19,14 @@ class ApplicationController < ActionController::Base
end
def load_tenant_data
if Rails.application.multi_tenancy?
return if request.subdomain.blank? or RESERVED_SUBDOMAINS.include?(request.subdomain)
current_tenant = get_tenant_from_request(request)
# Load the current tenant based on subdomain
current_tenant = Tenant.find_by(subdomain: request.subdomain)
if current_tenant.status == "pending" and controller_name != "confirmation" and action_name != "show"
redirect_to pending_tenant_path; return
end
if current_tenant.status == "pending" and controller_name != "confirmation" and action_name != "show"
redirect_to pending_tenant_path; return
end
if current_tenant.status == "blocked"
redirect_to blocked_tenant_path; return
end
redirect_to showcase_url unless current_tenant
else
# Load the one and only tenant
current_tenant = Tenant.first
if current_tenant.status == "blocked"
redirect_to blocked_tenant_path; return
end
return unless current_tenant