mirror of
https://github.com/astuto/astuto.git
synced 2025-12-16 11:47:56 +01:00
Add Site settings > General (#133)
This commit is contained in:
committed by
GitHub
parent
bdc4004e4a
commit
35831b9801
@@ -4,7 +4,7 @@ class ApplicationController < ActionController::Base
|
||||
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
|
||||
|
||||
before_action :configure_permitted_parameters, if: :devise_controller?
|
||||
before_action :load_boards
|
||||
prepend_before_action :load_tenant_data
|
||||
|
||||
protected
|
||||
|
||||
@@ -15,8 +15,36 @@ class ApplicationController < ActionController::Base
|
||||
devise_parameter_sanitizer.permit(:account_update, keys: additional_permitted_parameters)
|
||||
end
|
||||
|
||||
def load_boards
|
||||
def load_tenant_data
|
||||
if Rails.application.multi_tenancy?
|
||||
return if request.subdomain.blank? or RESERVED_SUBDOMAINS.include?(request.subdomain)
|
||||
|
||||
# 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 == "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
|
||||
end
|
||||
|
||||
return unless current_tenant
|
||||
Current.tenant = current_tenant
|
||||
|
||||
# Load tenant data
|
||||
@tenant = Current.tenant_or_raise!
|
||||
@boards = Board.select(:id, :name).order(order: :asc)
|
||||
|
||||
# Setup locale
|
||||
I18n.locale = @tenant.locale
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
Reference in New Issue
Block a user