nuxt-users 1.37.3 → 1.38.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 +1 -1
- package/dist/module.mjs +4 -0
- package/dist/runtime/middleware/authorization.client.js +4 -1
- package/dist/runtime/plugin.auth-init.d.ts +9 -0
- package/dist/runtime/plugin.auth-init.js +16 -0
- package/package.json +2 -2
- package/dist/runtime/plugin.client.d.ts +0 -2
- package/dist/runtime/plugin.client.js +0 -6
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -144,6 +144,10 @@ const module$1 = defineNuxtModule({
|
|
|
144
144
|
},
|
|
145
145
|
apiBasePath: runtimeConfigOptions.apiBasePath || defaultOptions.apiBasePath
|
|
146
146
|
};
|
|
147
|
+
addPlugin({
|
|
148
|
+
src: resolver.resolve("./runtime/plugin.auth-init"),
|
|
149
|
+
name: "0-auth-init-nuxt-users"
|
|
150
|
+
});
|
|
147
151
|
addPlugin({
|
|
148
152
|
src: resolver.resolve("./runtime/plugin"),
|
|
149
153
|
mode: "server"
|
|
@@ -18,7 +18,10 @@ export default defineNuxtRouteMiddleware(async (to) => {
|
|
|
18
18
|
console.log(`[Nuxt Users] client.middleware.auth.global: Whitelisted: ${to.path}`);
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
|
-
const { isAuthenticated, user, fetchUser } = useAuthentication();
|
|
21
|
+
const { isAuthenticated, user, fetchUser, initializeUser } = useAuthentication();
|
|
22
|
+
if (!isAuthenticated.value) {
|
|
23
|
+
await initializeUser();
|
|
24
|
+
}
|
|
22
25
|
if (!isAuthenticated.value && to.query?.oauth_success === "true") {
|
|
23
26
|
try {
|
|
24
27
|
await fetchUser(true);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Early authentication initialization plugin
|
|
3
|
+
*
|
|
4
|
+
* This plugin runs early (name starts with '0') to ensure authentication state
|
|
5
|
+
* is initialized from cookies before middleware runs. This prevents redirects
|
|
6
|
+
* to login page when opening new tabs with valid session cookies.
|
|
7
|
+
*/
|
|
8
|
+
declare const _default: import("#app").Plugin<Record<string, unknown>> & import("#app").ObjectPlugin<Record<string, unknown>>;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { defineNuxtPlugin } from "#app";
|
|
2
|
+
import { useAuthentication } from "./composables/useAuthentication.js";
|
|
3
|
+
export default defineNuxtPlugin(async () => {
|
|
4
|
+
if (import.meta.server) {
|
|
5
|
+
const { fetchUser } = useAuthentication();
|
|
6
|
+
try {
|
|
7
|
+
await fetchUser(true);
|
|
8
|
+
} catch {
|
|
9
|
+
}
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
if (import.meta.client) {
|
|
13
|
+
const { initializeUser } = useAuthentication();
|
|
14
|
+
await initializeUser();
|
|
15
|
+
}
|
|
16
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-users",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.38.0",
|
|
4
4
|
"description": "A comprehensive user management module for Nuxt 3 and Nuxt 4 applications with authentication, authorization, database support, and CLI tools",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nuxt",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"build": "nuxt-module-build build",
|
|
64
64
|
"postbuild": "node scripts/post-build.js",
|
|
65
65
|
"prerelease": "node -v | grep -q 'v22' || (echo 'Please use Node.js v22 for deployment' && exit 1)",
|
|
66
|
-
"release": "yarn lint && yarn test && yarn prepack && changelogen --release &&
|
|
66
|
+
"release": "yarn lint && yarn test && yarn prepack && changelogen --release && npm publish && git push --follow-tags",
|
|
67
67
|
"lint": "eslint .",
|
|
68
68
|
"lint:fix": "eslint . --fix",
|
|
69
69
|
"pretest": "node -v | grep -q 'v22' || (echo 'Please use Node.js v22 for testing' && exit 1)",
|