@bagelink/auth 1.9.112 → 1.9.114
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.
- package/dist/index.cjs +6 -2
- package/dist/index.mjs +6 -2
- package/dist/useAuth.d.ts +5 -0
- package/package.json +1 -1
- package/src/useAuth.ts +11 -4
package/dist/index.cjs
CHANGED
|
@@ -1986,6 +1986,7 @@ let eventEmitter = null;
|
|
|
1986
1986
|
let redirectConfig = null;
|
|
1987
1987
|
let autoRedirectRouter = null;
|
|
1988
1988
|
let cachedAuthGuard = null;
|
|
1989
|
+
let tenancyEnabled = false;
|
|
1989
1990
|
const accountInfo = vue.ref(null);
|
|
1990
1991
|
const tenants = vue.ref([]);
|
|
1991
1992
|
const currentTenant = vue.ref(null);
|
|
@@ -2005,6 +2006,7 @@ function createAuth(params) {
|
|
|
2005
2006
|
if (params.redirect) {
|
|
2006
2007
|
redirectConfig = normalizeRedirectConfig(params.redirect);
|
|
2007
2008
|
}
|
|
2009
|
+
tenancyEnabled = params.tenancy ?? false;
|
|
2008
2010
|
if (redirectConfig == null ? void 0 : redirectConfig.autoRedirect) {
|
|
2009
2011
|
setupAutoRedirect();
|
|
2010
2012
|
}
|
|
@@ -2189,8 +2191,10 @@ function useAuth() {
|
|
|
2189
2191
|
accountInfo.value = data;
|
|
2190
2192
|
if (getIsLoggedIn()) {
|
|
2191
2193
|
emitter.emit(AuthState.AUTH_CHECK);
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
+
if (tenancyEnabled) {
|
|
2195
|
+
await loadTenants().catch(() => {
|
|
2196
|
+
});
|
|
2197
|
+
}
|
|
2194
2198
|
}
|
|
2195
2199
|
return true;
|
|
2196
2200
|
} catch {
|
package/dist/index.mjs
CHANGED
|
@@ -1984,6 +1984,7 @@ let eventEmitter = null;
|
|
|
1984
1984
|
let redirectConfig = null;
|
|
1985
1985
|
let autoRedirectRouter = null;
|
|
1986
1986
|
let cachedAuthGuard = null;
|
|
1987
|
+
let tenancyEnabled = false;
|
|
1987
1988
|
const accountInfo = ref(null);
|
|
1988
1989
|
const tenants = ref([]);
|
|
1989
1990
|
const currentTenant = ref(null);
|
|
@@ -2003,6 +2004,7 @@ function createAuth(params) {
|
|
|
2003
2004
|
if (params.redirect) {
|
|
2004
2005
|
redirectConfig = normalizeRedirectConfig(params.redirect);
|
|
2005
2006
|
}
|
|
2007
|
+
tenancyEnabled = params.tenancy ?? false;
|
|
2006
2008
|
if (redirectConfig == null ? void 0 : redirectConfig.autoRedirect) {
|
|
2007
2009
|
setupAutoRedirect();
|
|
2008
2010
|
}
|
|
@@ -2187,8 +2189,10 @@ function useAuth() {
|
|
|
2187
2189
|
accountInfo.value = data;
|
|
2188
2190
|
if (getIsLoggedIn()) {
|
|
2189
2191
|
emitter.emit(AuthState.AUTH_CHECK);
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
+
if (tenancyEnabled) {
|
|
2193
|
+
await loadTenants().catch(() => {
|
|
2194
|
+
});
|
|
2195
|
+
}
|
|
2192
2196
|
}
|
|
2193
2197
|
return true;
|
|
2194
2198
|
} catch {
|
package/dist/useAuth.d.ts
CHANGED
|
@@ -8,6 +8,11 @@ interface InitParams {
|
|
|
8
8
|
* @see RedirectConfig
|
|
9
9
|
*/
|
|
10
10
|
redirect?: RedirectConfig;
|
|
11
|
+
/**
|
|
12
|
+
* Enable multi-tenancy support. When true, tenants are loaded after auth check.
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
tenancy?: boolean;
|
|
11
16
|
}
|
|
12
17
|
/**
|
|
13
18
|
* Auth instance returned by createAuth
|
package/package.json
CHANGED
package/src/useAuth.ts
CHANGED
|
@@ -26,6 +26,7 @@ let eventEmitter: EventEmitter | null = null
|
|
|
26
26
|
let redirectConfig: NormalizedRedirectConfig | null = null
|
|
27
27
|
let autoRedirectRouter: any = null // Router instance for auto-redirect
|
|
28
28
|
let cachedAuthGuard: any = null // Cached router guard
|
|
29
|
+
let tenancyEnabled = false
|
|
29
30
|
const accountInfo = ref<AccountInfo | null>(null)
|
|
30
31
|
const tenants = ref<TenantInfo[]>([])
|
|
31
32
|
const currentTenant = ref<TenantInfo | null>(null)
|
|
@@ -37,6 +38,11 @@ interface InitParams {
|
|
|
37
38
|
* @see RedirectConfig
|
|
38
39
|
*/
|
|
39
40
|
redirect?: RedirectConfig
|
|
41
|
+
/**
|
|
42
|
+
* Enable multi-tenancy support. When true, tenants are loaded after auth check.
|
|
43
|
+
* @default false
|
|
44
|
+
*/
|
|
45
|
+
tenancy?: boolean
|
|
40
46
|
}
|
|
41
47
|
|
|
42
48
|
/**
|
|
@@ -78,6 +84,8 @@ export function createAuth(params: InitParams): AuthInstance {
|
|
|
78
84
|
redirectConfig = normalizeRedirectConfig(params.redirect)
|
|
79
85
|
}
|
|
80
86
|
|
|
87
|
+
tenancyEnabled = params.tenancy ?? false
|
|
88
|
+
|
|
81
89
|
// Setup auto-redirect on login if enabled
|
|
82
90
|
if (redirectConfig?.autoRedirect) {
|
|
83
91
|
setupAutoRedirect()
|
|
@@ -310,10 +318,9 @@ export function useAuth() {
|
|
|
310
318
|
accountInfo.value = data
|
|
311
319
|
if (getIsLoggedIn()) {
|
|
312
320
|
emitter.emit(AuthState.AUTH_CHECK)
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
})
|
|
321
|
+
if (tenancyEnabled) {
|
|
322
|
+
await loadTenants().catch(() => {})
|
|
323
|
+
}
|
|
317
324
|
}
|
|
318
325
|
return true
|
|
319
326
|
} catch {
|