@meistrari/auth-nuxt 3.4.2 → 3.5.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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@meistrari/auth-nuxt",
3
3
  "configKey": "telaAuth",
4
- "version": "3.4.2",
4
+ "version": "3.5.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -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 { login, logout: sdkLogout } = useTelaApplicationAuth();
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
- await login();
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.4.2",
3
+ "version": "3.5.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {