@meistrari/auth-nuxt 3.4.2 → 3.6.0
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/module.json
CHANGED
|
@@ -46,8 +46,12 @@ export interface UseTelaOrganizationReturn {
|
|
|
46
46
|
/**
|
|
47
47
|
* Accepts an organization invitation and updates the active organization state.
|
|
48
48
|
* @param id - The invitation ID to accept
|
|
49
|
+
* @returns Object containing the application's `homeUrl` when the invitation is
|
|
50
|
+
* scoped to an application that defines one; otherwise `null`.
|
|
49
51
|
*/
|
|
50
|
-
acceptInvitation: (id: string) => Promise<
|
|
52
|
+
acceptInvitation: (id: string) => Promise<{
|
|
53
|
+
homeUrl: string | null;
|
|
54
|
+
}>;
|
|
51
55
|
/**
|
|
52
56
|
* Cancels a pending organization invitation and updates the active organization state.
|
|
53
57
|
* @param id - The invitation ID to cancel
|
|
@@ -58,7 +58,7 @@ export function useTelaOrganization() {
|
|
|
58
58
|
return invitation;
|
|
59
59
|
}
|
|
60
60
|
async function acceptInvitation(id) {
|
|
61
|
-
await authClient.organization.acceptInvitation(id);
|
|
61
|
+
const { homeUrl } = await authClient.organization.acceptInvitation(id);
|
|
62
62
|
const members = await authClient.organization.listMembers();
|
|
63
63
|
if (activeOrganization.value) {
|
|
64
64
|
activeOrganization.value = {
|
|
@@ -66,6 +66,7 @@ export function useTelaOrganization() {
|
|
|
66
66
|
members
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
|
+
return { homeUrl };
|
|
69
70
|
}
|
|
70
71
|
async function cancelInvitation(id) {
|
|
71
72
|
await authClient.organization.cancelInvitation(id);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineNuxtPlugin, useCookie, useRuntimeConfig } from "#app";
|
|
1
|
+
import { defineNuxtPlugin, navigateTo, useCookie, useRoute, useRuntimeConfig } from "#app";
|
|
2
2
|
import { isTokenExpired } from "@meistrari/auth-core";
|
|
3
3
|
import { useTelaApplicationAuth } from "../composables/application-auth.js";
|
|
4
4
|
import { useApplicationSessionState } from "../composables/state.js";
|
|
@@ -16,7 +16,11 @@ export default defineNuxtPlugin({
|
|
|
16
16
|
async setup() {
|
|
17
17
|
const appConfig = useRuntimeConfig().public.telaAuth;
|
|
18
18
|
const state = useApplicationSessionState();
|
|
19
|
-
const {
|
|
19
|
+
const { logout: sdkLogout } = useTelaApplicationAuth();
|
|
20
|
+
const route = useRoute();
|
|
21
|
+
const loginPath = appConfig.application?.loginPath ?? "/login";
|
|
22
|
+
const unauthorizedPath = appConfig.application?.unauthorizedPath ?? "/unauthorized";
|
|
23
|
+
const exemptPaths = [loginPath, unauthorizedPath];
|
|
20
24
|
const accessTokenCookie = useCookie("tela-access-token", {
|
|
21
25
|
secure: !import.meta.dev,
|
|
22
26
|
sameSite: "lax",
|
|
@@ -55,7 +59,13 @@ export default defineNuxtPlugin({
|
|
|
55
59
|
} catch {
|
|
56
60
|
await sdkLogout();
|
|
57
61
|
if (import.meta.client) {
|
|
58
|
-
|
|
62
|
+
const currentPath = decodeURI(route.path);
|
|
63
|
+
if (!exemptPaths.includes(currentPath)) {
|
|
64
|
+
await navigateTo({
|
|
65
|
+
path: loginPath,
|
|
66
|
+
query: { returnTo: route.fullPath }
|
|
67
|
+
});
|
|
68
|
+
}
|
|
59
69
|
}
|
|
60
70
|
} finally {
|
|
61
71
|
isRefreshing = false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meistrari/auth-nuxt",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"docs": "nuxt-module-build prepare && typedoc"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@meistrari/auth-core": "
|
|
39
|
+
"@meistrari/auth-core": "workspace:*",
|
|
40
40
|
"jose": "6.1.3"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|