nuxt-users 1.42.0 → 1.44.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
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.0.0"
6
6
  },
7
- "version": "1.42.0",
7
+ "version": "1.44.0",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { defineNuxtModule, createResolver, addPlugin, addImportsDir, addServerImportsDir, addServerScanDir, addServerHandler, addRouteMiddleware, addComponentsDir } from '@nuxt/kit';
1
+ import { defineNuxtModule, createResolver, addPlugin, addImportsDir, addServerImportsDir, addServerScanDir, addServerHandler, addServerPlugin, addRouteMiddleware, addComponentsDir } from '@nuxt/kit';
2
2
  import { defu } from 'defu';
3
3
  export * from '../dist/runtime/server/internal/index.js';
4
4
 
@@ -181,6 +181,7 @@ const module$1 = defineNuxtModule({
181
181
  middleware: true,
182
182
  handler: resolver.resolve("./runtime/server/middleware/authorization.server")
183
183
  });
184
+ addServerPlugin(resolver.resolve("./runtime/server/plugins/auto-migrate"));
184
185
  addRouteMiddleware({
185
186
  name: "authorization.client",
186
187
  path: resolver.resolve("./runtime/middleware/authorization.client"),
@@ -1,4 +1,4 @@
1
- import { useState, useRuntimeConfig, useFetch } from "#app";
1
+ import { useState, useRuntimeConfig, useFetch, useRequestHeaders } from "#app";
2
2
  import { computed, readonly } from "vue";
3
3
  let initializationPromise = null;
4
4
  export const useAuthentication = () => {
@@ -40,9 +40,11 @@ export const useAuthentication = () => {
40
40
  try {
41
41
  let userData = null;
42
42
  if (useSSR) {
43
+ const headers = useRequestHeaders(["cookie"]);
43
44
  const { data, error } = await useFetch(`${apiBasePath}/me`, {
44
45
  server: true,
45
- lazy: false
46
+ lazy: false,
47
+ ...Object.keys(headers).length ? { headers } : {}
46
48
  });
47
49
  if (error.value) {
48
50
  const statusCode = error.value.statusCode || error.value.status;
@@ -15,9 +15,7 @@ export default defineEventHandler(async (event) => {
15
15
  const newUser = await createUser({
16
16
  email: body.email,
17
17
  name: body.name,
18
- password: body.password,
19
- role: body.role
20
- // role is optional
18
+ password: body.password
21
19
  }, options);
22
20
  return { user: newUser };
23
21
  } catch (error) {
@@ -0,0 +1,3 @@
1
+ import type { NitroAppPlugin } from 'nitropack';
2
+ declare const plugin: NitroAppPlugin;
3
+ export default plugin;
@@ -0,0 +1,14 @@
1
+ import { useRuntimeConfig } from "#imports";
2
+ import { runMigrations } from "../utils/index.js";
3
+ const plugin = async () => {
4
+ const config = useRuntimeConfig();
5
+ if (!config.nuxtUsers) {
6
+ return;
7
+ }
8
+ try {
9
+ await runMigrations(config.nuxtUsers);
10
+ } catch (error) {
11
+ console.error("[Nuxt Users] Auto-migration failed:", error);
12
+ }
13
+ };
14
+ export default plugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-users",
3
- "version": "1.42.0",
3
+ "version": "1.44.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",
@@ -48,7 +48,7 @@ echo "Running tests against MySQL..."
48
48
  # Check if any arguments were passed
49
49
  if [ $# -eq 0 ]; then
50
50
  # Run all tests except unit tests (database-independent)
51
- vitest run --exclude="test/unit/"
51
+ npx vitest run --exclude="test/unit/"
52
52
  else
53
- vitest run "$@"
53
+ npx vitest run "$@"
54
54
  fi