@michael-nussbaumer/nuxt-directus 0.2.4 → 0.2.6
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/README.md
CHANGED
|
@@ -117,15 +117,15 @@ definePageMeta({
|
|
|
117
117
|
|
|
118
118
|
Comprehensive guides for all module features:
|
|
119
119
|
|
|
120
|
-
- **[Getting Started](https://michael-nussbaumer.github.io/nuxt-directus-module/getting-started)** - Installation, setup, and basic usage
|
|
121
|
-
- **[Configuration](https://michael-nussbaumer.github.io/nuxt-directus-module/configuration)** - Module options and environment variables
|
|
122
|
-
- **[Authentication](https://michael-nussbaumer.github.io/nuxt-directus-module/authentication)** - Login, logout, registration, and user management
|
|
123
|
-
- **[API Usage](https://michael-nussbaumer.github.io/nuxt-directus-module/api)** - CRUD operations, queries, and filtering
|
|
124
|
-
- **[Real-time WebSocket](https://michael-nussbaumer.github.io/nuxt-directus-module/realtime)** - Live subscriptions and event handling
|
|
125
|
-
- **[Middleware](https://michael-nussbaumer.github.io/nuxt-directus-module/middleware)** - Route protection and authentication flows
|
|
126
|
-
- **[
|
|
127
|
-
- **[Type Generation](https://michael-nussbaumer.github.io/nuxt-directus-module/type-generation)** - Automatic TypeScript types from OpenAPI schema
|
|
128
|
-
- **[Examples](https://michael-nussbaumer.github.io/nuxt-directus-module/examples)** - Code examples and use cases
|
|
120
|
+
- **[Getting Started](https://michael-nussbaumer.github.io/nuxt-directus-module/getting-started/installation)** - Installation, setup, and basic usage
|
|
121
|
+
- **[Configuration](https://michael-nussbaumer.github.io/nuxt-directus-module/getting-started/configuration)** - Module options and environment variables
|
|
122
|
+
- **[Authentication](https://michael-nussbaumer.github.io/nuxt-directus-module/guides/authentication)** - Login, logout, registration, and user management
|
|
123
|
+
- **[API Usage](https://michael-nussbaumer.github.io/nuxt-directus-module/guides/api)** - CRUD operations, queries, and filtering
|
|
124
|
+
- **[Real-time WebSocket](https://michael-nussbaumer.github.io/nuxt-directus-module/guides/realtime)** - Live subscriptions and event handling
|
|
125
|
+
- **[Middleware](https://michael-nussbaumer.github.io/nuxt-directus-module/guides/middleware)** - Route protection and authentication flows
|
|
126
|
+
- **[Permissions](https://michael-nussbaumer.github.io/nuxt-directus-module/guides/permissions)** - Advanced access control
|
|
127
|
+
- **[Type Generation](https://michael-nussbaumer.github.io/nuxt-directus-module/guides/type-generation)** - Automatic TypeScript types from OpenAPI schema
|
|
128
|
+
- **[Examples](https://michael-nussbaumer.github.io/nuxt-directus-module/examples/examples)** - Code examples and use cases
|
|
129
129
|
|
|
130
130
|
Or browse the [docs folder](./docs) in this repository.
|
|
131
131
|
|
|
@@ -231,6 +231,4 @@ https://github.com/Michael-Nussbaumer/nuxt-directus-module
|
|
|
231
231
|
|
|
232
232
|
## Documentation Site
|
|
233
233
|
|
|
234
|
-
The documentation is hosted on GitHub Pages. To set it up for the first time, see [GITHUB_PAGES_SETUP.md](./GITHUB_PAGES_SETUP.md).
|
|
235
|
-
|
|
236
234
|
Visit: https://michael-nussbaumer.github.io/nuxt-directus-module/
|
package/dist/module.json
CHANGED
|
@@ -169,6 +169,10 @@ export const useDirectusAuth = () => {
|
|
|
169
169
|
return true;
|
|
170
170
|
} catch (e) {
|
|
171
171
|
error.value = e.message || "Token refresh failed";
|
|
172
|
+
const refreshTokenCookie = useCookie("directus_refresh_token");
|
|
173
|
+
refreshTokenCookie.value = null;
|
|
174
|
+
const dataCookie = useCookie("directus-data");
|
|
175
|
+
dataCookie.value = null;
|
|
172
176
|
throw e;
|
|
173
177
|
} finally {
|
|
174
178
|
isLoading.value = false;
|
package/dist/runtime/directus.js
CHANGED
|
@@ -78,8 +78,17 @@ export default defineNuxtPlugin(async () => {
|
|
|
78
78
|
}
|
|
79
79
|
return me;
|
|
80
80
|
} catch (error) {
|
|
81
|
+
if (import.meta.dev) {
|
|
82
|
+
console.log("[Directus] Authentication failed:", error);
|
|
83
|
+
}
|
|
81
84
|
isAuthenticatedState.value = false;
|
|
82
85
|
currentUser.value = null;
|
|
86
|
+
if (import.meta.client) {
|
|
87
|
+
const refreshTokenCookie = useCookie("directus_refresh_token");
|
|
88
|
+
refreshTokenCookie.value = null;
|
|
89
|
+
const dataCookie = useCookie("directus-data");
|
|
90
|
+
dataCookie.value = null;
|
|
91
|
+
}
|
|
83
92
|
return false;
|
|
84
93
|
}
|
|
85
94
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { defineNuxtRouteMiddleware, navigateTo, useRuntimeConfig, useCookie } from "#app";
|
|
2
2
|
import { useDirectusAuth } from "../composables/useDirectusAuth.js";
|
|
3
3
|
export default defineNuxtRouteMiddleware(async (to, from) => {
|
|
4
|
-
const { isAuthenticated
|
|
4
|
+
const { isAuthenticated } = useDirectusAuth();
|
|
5
5
|
const config = useRuntimeConfig();
|
|
6
|
+
const { $directusAuth } = useNuxtApp();
|
|
6
7
|
const { loginPath, registerPath, afterLoginPath } = config.public.directus?.auth || {
|
|
7
8
|
loginPath: "/login",
|
|
8
9
|
registerPath: "/register",
|
|
@@ -33,12 +34,7 @@ export default defineNuxtRouteMiddleware(async (to, from) => {
|
|
|
33
34
|
return;
|
|
34
35
|
}
|
|
35
36
|
try {
|
|
36
|
-
|
|
37
|
-
try {
|
|
38
|
-
await fetchUser();
|
|
39
|
-
} catch {
|
|
40
|
-
}
|
|
41
|
-
}
|
|
37
|
+
await $directusAuth.checkAuthStatus();
|
|
42
38
|
const authenticated = isAuthenticated.value;
|
|
43
39
|
if (!authenticated) {
|
|
44
40
|
if (authMeta?.unauthenticatedOnly) {
|
|
@@ -72,7 +68,7 @@ export default defineNuxtRouteMiddleware(async (to, from) => {
|
|
|
72
68
|
}
|
|
73
69
|
const permissionsConfig = config.public.directus?.auth?.permissions;
|
|
74
70
|
if (permissionsConfig?.enabled && (authMeta?.roles || authMeta?.excludeRoles)) {
|
|
75
|
-
const currentUser =
|
|
71
|
+
const currentUser = $directusAuth.currentUser.value;
|
|
76
72
|
if (currentUser) {
|
|
77
73
|
const roleField = permissionsConfig.field || "role";
|
|
78
74
|
let userRoleValue = currentUser[roleField];
|