@innertia-solutions/innertia-nuxt 0.1.67 → 0.1.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// useTenantSelection, useActiveTenantStore, useAppConfig auto-imported.
|
|
1
|
+
// useTenantSelection, useActiveTenantStore, useOrganizationStore, useAppConfig auto-imported.
|
|
2
2
|
//
|
|
3
3
|
// Modo 'open' — login personal unificado.
|
|
4
4
|
//
|
|
@@ -65,6 +65,8 @@ export function useLoginDestinations() {
|
|
|
65
65
|
|
|
66
66
|
/** Fija el tenant + contexto activos y navega a la home del contexto elegido. */
|
|
67
67
|
async function go(destination) {
|
|
68
|
+
// Cambio de tenant → limpiar la sede activa (la cookie de orgs no está keyed por tenant).
|
|
69
|
+
if (destination.tenantKey !== store.activeKey) useOrganizationStore().reset()
|
|
68
70
|
store.setActive(destination.tenantKey)
|
|
69
71
|
store.setActiveContext(destination.context)
|
|
70
72
|
await navigateTo(destination.home)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// useApi, useActiveTenantStore auto-imported.
|
|
1
|
+
// useApi, useActiveTenantStore, useOrganizationStore auto-imported.
|
|
2
2
|
// Selección de tenant en modo 'open': carga los tenants del usuario y resuelve
|
|
3
3
|
// el destino post-login según cuántos tenga (0 / 1 / 2+).
|
|
4
4
|
|
|
@@ -6,6 +6,16 @@ export function useTenantSelection() {
|
|
|
6
6
|
const api = useApi()
|
|
7
7
|
const store = useActiveTenantStore()
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Activa un tenant. Si cambia, resetea la sede (org) activa: la cookie de orgs
|
|
11
|
+
* está keyed por contexto, no por tenant, y una sede del tenant anterior
|
|
12
|
+
* viajaría en X-Organization (→ 401/403 en el backend).
|
|
13
|
+
*/
|
|
14
|
+
function activate(key) {
|
|
15
|
+
if (key !== store.activeKey) useOrganizationStore().reset()
|
|
16
|
+
store.setActive(key)
|
|
17
|
+
}
|
|
18
|
+
|
|
9
19
|
/** Carga los tenants del usuario autenticado y los guarda en el store. */
|
|
10
20
|
async function load() {
|
|
11
21
|
// El backend aún expone la ruta gym-flavored: { gyms: [{ key, name, status, contexts }] }
|
|
@@ -23,13 +33,13 @@ export function useTenantSelection() {
|
|
|
23
33
|
async function resolveAfterLogin() {
|
|
24
34
|
await load()
|
|
25
35
|
if (store.tenants.length === 0) return 'onboarding'
|
|
26
|
-
if (store.tenants.length === 1) {
|
|
36
|
+
if (store.tenants.length === 1) { activate(store.tenants[0].key); return 'ready' }
|
|
27
37
|
if (store.activeKey && store.tenants.some((t) => t.key === store.activeKey)) return 'ready'
|
|
28
38
|
return 'picker'
|
|
29
39
|
}
|
|
30
40
|
|
|
31
41
|
/** Cambia el tenant activo (switcher). */
|
|
32
|
-
function switchTo(key) {
|
|
42
|
+
function switchTo(key) { activate(key) }
|
|
33
43
|
|
|
34
44
|
return { load, resolveAfterLogin, switchTo }
|
|
35
45
|
}
|