mirror of
https://github.com/astuto/astuto.git
synced 2025-12-16 11:47:56 +01:00
Add custom domains (#314)
This commit is contained in:
committed by
GitHub
parent
d47c70f576
commit
d17b45c5c4
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user