Fix business tenant binding and update password on cross-site signup.

Resolve the active business from the host domain so multi-business staff no longer load another tenant’s CMS data, and replace the Meshkee password when linking an existing account to a new site.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Alireza Hassani
2026-08-21 12:07:17 +03:30
co-authored by Cursor
parent 193c63bfd2
commit 89269dff04
6 changed files with 52 additions and 50 deletions
+5 -3
View File
@@ -4,12 +4,14 @@ import { getBusinessDomain } from './config'
const ACTIVE_BUSINESS_ID_KEY = 'meshkee_active_business_id'
const ACTIVE_BUSINESS_DOMAIN_KEY = 'meshkee_active_business_domain'
export function setActiveBusiness(user: AuthUser) {
/** Prefer resolving the host tenant, then {@link setActiveBusinessById}. */
export function setActiveBusiness(user: AuthUser, businessId?: string) {
const domain = getBusinessDomain()
localStorage.setItem(ACTIVE_BUSINESS_DOMAIN_KEY, domain)
if (user.businesses.length > 0) {
localStorage.setItem(ACTIVE_BUSINESS_ID_KEY, String(user.businesses[0].id))
const id = businessId ?? (user.businesses[0] ? String(user.businesses[0].id) : null)
if (id) {
localStorage.setItem(ACTIVE_BUSINESS_ID_KEY, id)
}
}