nuxt-users 1.15.0 → 1.15.2

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/CHANGELOG.md CHANGED
@@ -1,6 +1,45 @@
1
1
  # Changelog
2
2
 
3
3
 
4
+ ## v1.15.2
5
+
6
+ [compare changes](https://github.com/rrd108/nuxt-users/compare/v1.15.1...v1.15.2)
7
+
8
+ ### 🩹 Fixes
9
+
10
+ - Import path ([1d1013e](https://github.com/rrd108/nuxt-users/commit/1d1013e))
11
+ - Add export ([90ce9b0](https://github.com/rrd108/nuxt-users/commit/90ce9b0))
12
+ - Dynamic imports ([26ff073](https://github.com/rrd108/nuxt-users/commit/26ff073))
13
+
14
+ ### 🏡 Chore
15
+
16
+ - **release:** V1.15.1 ([214661b](https://github.com/rrd108/nuxt-users/commit/214661b))
17
+
18
+ ### ❤️ Contributors
19
+
20
+ - Rrd108 ([@rrd108](https://github.com/rrd108))
21
+
22
+ ## v1.15.1
23
+
24
+ [compare changes](https://github.com/rrd108/nuxt-users/compare/v1.15.0...v1.15.1)
25
+
26
+ ### 🩹 Fixes
27
+
28
+ - Import path ([1d1013e](https://github.com/rrd108/nuxt-users/commit/1d1013e))
29
+
30
+ ### 💅 Refactors
31
+
32
+ - GetCurrentUser from a utility to a composable ([10149d2](https://github.com/rrd108/nuxt-users/commit/10149d2))
33
+
34
+ ### 🏡 Chore
35
+
36
+ - Fix whitespace ([517d60d](https://github.com/rrd108/nuxt-users/commit/517d60d))
37
+ - **release:** V1.15.0 ([2cc5d6a](https://github.com/rrd108/nuxt-users/commit/2cc5d6a))
38
+
39
+ ### ❤️ Contributors
40
+
41
+ - Rrd108 ([@rrd108](https://github.com/rrd108))
42
+
4
43
  ## v1.15.0
5
44
 
6
45
  [compare changes](https://github.com/rrd108/nuxt-users/compare/v1.14.0...v1.15.0)
package/dist/cli.mjs CHANGED
@@ -247,7 +247,7 @@ const main = defineCommand({
247
247
  meta: {
248
248
  name: "nuxt-users",
249
249
  description: "CLI for Nuxt Users Module - Manage users, migrations, and database operations",
250
- version: "1.14.0"
250
+ version: "1.15.1"
251
251
  },
252
252
  subCommands: {
253
253
  migrate,
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-users",
3
3
  "configKey": "nuxtUsers",
4
- "version": "1.15.0",
4
+ "version": "1.15.2",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.0"
@@ -1,5 +1,22 @@
1
- import { type H3Event } from 'h3';
2
1
  import type { UserWithoutPassword } from '../../types.js';
2
+ /**
3
+ * Server-side composable for authentication utilities
4
+ *
5
+ * @example
6
+ * ```typescript
7
+ * // server/api/protected-route.get.ts
8
+ * export default defineEventHandler(async (event) => {
9
+ * const { getCurrentUser } = useServerAuth()
10
+ * const user = await getCurrentUser(event)
11
+ *
12
+ * if (!user) {
13
+ * throw createError({ statusCode: 401, statusMessage: 'Unauthorized' })
14
+ * }
15
+ *
16
+ * return { message: `Hello ${user.name}!` }
17
+ * })
18
+ * ```
19
+ */
3
20
  export declare const useServerAuth: () => {
4
- getCurrentUser: (event: H3Event) => Promise<UserWithoutPassword | null>;
21
+ getCurrentUser: (event: unknown) => Promise<UserWithoutPassword | null>;
5
22
  };
@@ -1,16 +1,16 @@
1
1
  import { getCurrentUserFromToken } from "../server/utils/user.js";
2
- import { useRuntimeConfig } from "#imports";
3
- import { getCookie } from "h3";
4
- const getCurrentUser = async (event) => {
5
- const token = getCookie(event, "auth_token");
6
- if (!token) {
7
- return null;
8
- }
9
- const { nuxtUsers } = useRuntimeConfig();
10
- const user = await getCurrentUserFromToken(token, nuxtUsers, false);
11
- return user;
12
- };
13
2
  export const useServerAuth = () => {
3
+ const getCurrentUser = async (event) => {
4
+ const { useRuntimeConfig } = await import("#imports");
5
+ const { getCookie } = await import("h3");
6
+ const token = getCookie(event, "auth_token");
7
+ if (!token) {
8
+ return null;
9
+ }
10
+ const { nuxtUsers } = useRuntimeConfig();
11
+ const user = await getCurrentUserFromToken(token, nuxtUsers, false);
12
+ return user;
13
+ };
14
14
  return {
15
15
  getCurrentUser
16
16
  };
@@ -6,3 +6,4 @@ export { createPasswordResetTokensTable } from './create-password-reset-tokens-t
6
6
  export { createMigrationsTable } from './create-migrations-table.js';
7
7
  export { runMigrations } from './migrate.js';
8
8
  export { useNuxtUsersDatabase } from '../../composables/useNuxtUsersDatabase.js';
9
+ export { useServerAuth } from '../../composables/useServerAuth.js';
@@ -6,3 +6,4 @@ export { createPasswordResetTokensTable } from "./create-password-reset-tokens-t
6
6
  export { createMigrationsTable } from "./create-migrations-table.js";
7
7
  export { runMigrations } from "./migrate.js";
8
8
  export { useNuxtUsersDatabase } from "../../composables/useNuxtUsersDatabase.js";
9
+ export { useServerAuth } from "../../composables/useServerAuth.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-users",
3
- "version": "1.15.0",
3
+ "version": "1.15.2",
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",