Move setting Current.account into the middleware

so that code called from the Rails controllers can use Current.account
This commit is contained in:
Mike Dalessio
2025-11-13 18:58:51 -05:00
parent 56c41d45eb
commit 5a7f08067a
2 changed files with 4 additions and 13 deletions
+3 -13
View File
@@ -35,10 +35,8 @@ module Authentication
end
def require_account
if request_account_id.blank?
unless Current.account.present?
redirect_to session_menu_url(script_name: nil)
else
set_current_account
end
end
@@ -57,7 +55,7 @@ module Authentication
end
def request_authentication
if request_account_id.present?
if Current.account.present?
session[:return_to_after_authenticating] = request.url
end
@@ -73,7 +71,7 @@ module Authentication
end
def redirect_tenanted_request
redirect_to root_url if request_account_id
redirect_to root_url if Current.account.present?
end
def start_new_session_for(identity)
@@ -92,12 +90,4 @@ module Authentication
Current.session.destroy
cookies.delete(:session_token)
end
def set_current_account
Current.account = Account.find_by(external_account_id: request_account_id)
end
def request_account_id
request.env["fizzy.external_account_id"]
end
end
@@ -24,6 +24,7 @@ module AccountSlug
# Stash the account's Queenbee ID.
env["fizzy.external_account_id"] = AccountSlug.decode($2)
Current.account = Account.find_by(external_account_id: env["fizzy.external_account_id"])
end
@app.call env