nuxt-users 1.5.0 → 1.6.1
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 +49 -0
- package/dist/cli.mjs +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +2 -2
- package/dist/runtime/components/ProfileForm.vue +1 -1
- package/dist/runtime/server/api/profile.get.js +1 -1
- package/dist/runtime/server/api/{profile/update-password.post.js → update-password.post.js} +2 -2
- package/dist/shared/{nuxt-users.37k1R3_g.mjs → nuxt-users.C_UkhLJ9.mjs} +22 -1
- package/dist/utils.d.mts +5 -1
- package/dist/utils.d.ts +5 -1
- package/dist/utils.mjs +1 -1
- package/package.json +2 -2
- /package/dist/runtime/server/api/{profile/update-password.post.d.ts → update-password.post.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,55 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
## v1.6.1
|
|
5
|
+
|
|
6
|
+
[compare changes](https://github.com/rrd108/nuxt-users/compare/v1.6.0...v1.6.1)
|
|
7
|
+
|
|
8
|
+
### 🩹 Fixes
|
|
9
|
+
|
|
10
|
+
- Exports `getCurrentUserFromToken` from utils index ([5c67e24](https://github.com/rrd108/nuxt-users/commit/5c67e24))
|
|
11
|
+
|
|
12
|
+
### 💅 Refactors
|
|
13
|
+
|
|
14
|
+
- Move file to one level up ([e9111c0](https://github.com/rrd108/nuxt-users/commit/e9111c0))
|
|
15
|
+
|
|
16
|
+
### 🏡 Chore
|
|
17
|
+
|
|
18
|
+
- **release:** V1.6.0 ([1c9eab4](https://github.com/rrd108/nuxt-users/commit/1c9eab4))
|
|
19
|
+
|
|
20
|
+
### ❤️ Contributors
|
|
21
|
+
|
|
22
|
+
- Rrd108 ([@rrd108](https://github.com/rrd108))
|
|
23
|
+
|
|
24
|
+
## v1.6.0
|
|
25
|
+
|
|
26
|
+
[compare changes](https://github.com/rrd108/nuxt-users/compare/v1.5.0...v1.6.0)
|
|
27
|
+
|
|
28
|
+
### 🚀 Enhancements
|
|
29
|
+
|
|
30
|
+
- Add profile page closes #58 ([#58](https://github.com/rrd108/nuxt-users/issues/58))
|
|
31
|
+
|
|
32
|
+
### 🩹 Fixes
|
|
33
|
+
|
|
34
|
+
- Enhances user authentication and data handling ([d15c77f](https://github.com/rrd108/nuxt-users/commit/d15c77f))
|
|
35
|
+
|
|
36
|
+
### 💅 Refactors
|
|
37
|
+
|
|
38
|
+
- Module options and defaults ([00aa094](https://github.com/rrd108/nuxt-users/commit/00aa094))
|
|
39
|
+
- Move file to one level up ([e9111c0](https://github.com/rrd108/nuxt-users/commit/e9111c0))
|
|
40
|
+
|
|
41
|
+
### 🏡 Chore
|
|
42
|
+
|
|
43
|
+
- **release:** V1.5.0 ([c639fcf](https://github.com/rrd108/nuxt-users/commit/c639fcf))
|
|
44
|
+
|
|
45
|
+
### ✅ Tests
|
|
46
|
+
|
|
47
|
+
- Do not run unit tests for various dbs ([5b5e3aa](https://github.com/rrd108/nuxt-users/commit/5b5e3aa))
|
|
48
|
+
|
|
49
|
+
### ❤️ Contributors
|
|
50
|
+
|
|
51
|
+
- Rrd108 ([@rrd108](https://github.com/rrd108))
|
|
52
|
+
|
|
4
53
|
## v1.5.0
|
|
5
54
|
|
|
6
55
|
[compare changes](https://github.com/rrd108/nuxt-users/compare/v1.4.0...v1.5.0)
|
package/dist/cli.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { defineCommand, runMain } from 'citty';
|
|
3
3
|
import 'db0';
|
|
4
4
|
import 'bcrypt';
|
|
5
|
-
import { r as runMigrations,
|
|
5
|
+
import { r as runMigrations, j as getPasswordValidationOptions, v as validatePassword, a as createUser$1, d as createUsersTable$1, e as createPersonalAccessTokensTable$1, h as createPasswordResetTokensTable$1, i as createMigrationsTable$1 } from './shared/nuxt-users.C_UkhLJ9.mjs';
|
|
6
6
|
import { defaultOptions } from './module.mjs';
|
|
7
7
|
import { loadNuxt } from '@nuxt/kit';
|
|
8
8
|
import 'defu';
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -109,9 +109,9 @@ const module = defineNuxtModule({
|
|
|
109
109
|
handler: resolver.resolve("./runtime/server/api/profile.get")
|
|
110
110
|
});
|
|
111
111
|
addServerHandler({
|
|
112
|
-
route: "/api/
|
|
112
|
+
route: "/api/update-password",
|
|
113
113
|
method: "post",
|
|
114
|
-
handler: resolver.resolve("./runtime/server/api/
|
|
114
|
+
handler: resolver.resolve("./runtime/server/api/update-password.post")
|
|
115
115
|
});
|
|
116
116
|
addComponent({
|
|
117
117
|
name: "LoginForm",
|
|
@@ -5,7 +5,7 @@ import { useRuntimeConfig } from "#imports";
|
|
|
5
5
|
import PasswordStrengthIndicator from "./PasswordStrengthIndicator.vue";
|
|
6
6
|
const props = defineProps({
|
|
7
7
|
apiEndpoint: { type: String, required: false, default: "/api/profile" },
|
|
8
|
-
updatePasswordEndpoint: { type: String, required: false, default: "/api/
|
|
8
|
+
updatePasswordEndpoint: { type: String, required: false, default: "/api/update-password" }
|
|
9
9
|
});
|
|
10
10
|
const emit = defineEmits(["success", "error", "password-error", "password-updated"]);
|
|
11
11
|
const isLoading = ref(false);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createError, defineEventHandler, getCookie } from "h3";
|
|
2
2
|
import { useRuntimeConfig } from "#imports";
|
|
3
|
-
import { getCurrentUserFromToken } from "../../../utils
|
|
3
|
+
import { getCurrentUserFromToken } from "../../../utils";
|
|
4
4
|
export default defineEventHandler(async (event) => {
|
|
5
5
|
const { nuxtUsers } = useRuntimeConfig();
|
|
6
6
|
const options = nuxtUsers;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createError, defineEventHandler, getCookie, readBody } from "h3";
|
|
2
2
|
import bcrypt from "bcrypt";
|
|
3
3
|
import { useRuntimeConfig } from "#imports";
|
|
4
|
-
import { getCurrentUserFromToken, updateUserPassword } from "
|
|
5
|
-
import { validatePassword, getPasswordValidationOptions } from "
|
|
4
|
+
import { getCurrentUserFromToken, updateUserPassword } from "../../../utils/user";
|
|
5
|
+
import { validatePassword, getPasswordValidationOptions } from "../../../utils/password-validation";
|
|
6
6
|
export default defineEventHandler(async (event) => {
|
|
7
7
|
const { nuxtUsers } = useRuntimeConfig();
|
|
8
8
|
const options = nuxtUsers;
|
|
@@ -269,6 +269,27 @@ const updateUserPassword = async (email, newPassword, options) => {
|
|
|
269
269
|
WHERE email = ${email}
|
|
270
270
|
`;
|
|
271
271
|
};
|
|
272
|
+
const getCurrentUserFromToken = async (token, options) => {
|
|
273
|
+
const db = await useDb(options);
|
|
274
|
+
const personalAccessTokensTable = options.tables.personalAccessTokens;
|
|
275
|
+
const usersTable = options.tables.users;
|
|
276
|
+
const tokenResult = await db.sql`
|
|
277
|
+
SELECT tokenable_id FROM {${personalAccessTokensTable}}
|
|
278
|
+
WHERE token = ${token}
|
|
279
|
+
`;
|
|
280
|
+
if (tokenResult.rows.length === 0) {
|
|
281
|
+
return null;
|
|
282
|
+
}
|
|
283
|
+
const userId = tokenResult.rows[0].tokenable_id;
|
|
284
|
+
const userResult = await db.sql`
|
|
285
|
+
SELECT * FROM {${usersTable}}
|
|
286
|
+
WHERE id = ${userId}
|
|
287
|
+
`;
|
|
288
|
+
if (userResult.rows.length === 0) {
|
|
289
|
+
return null;
|
|
290
|
+
}
|
|
291
|
+
return userResult.rows[0];
|
|
292
|
+
};
|
|
272
293
|
|
|
273
294
|
const createUsersTable = async (options) => {
|
|
274
295
|
const connectorName = options.connector.name;
|
|
@@ -507,4 +528,4 @@ const runMigrations = async (options) => {
|
|
|
507
528
|
console.log("[Nuxt Users] All migrations successfull \u2705");
|
|
508
529
|
};
|
|
509
530
|
|
|
510
|
-
export { createUser as a, updateUserPassword as b, checkTableExists as c, createUsersTable as d, createPersonalAccessTokensTable as e, findUserByEmail as f,
|
|
531
|
+
export { createUser as a, updateUserPassword as b, checkTableExists as c, createUsersTable as d, createPersonalAccessTokensTable as e, findUserByEmail as f, getCurrentUserFromToken as g, createPasswordResetTokensTable as h, createMigrationsTable as i, getPasswordValidationOptions as j, getPasswordStrengthColor as k, getPasswordStrengthText as l, runMigrations as r, useDb as u, validatePassword as v };
|
package/dist/utils.d.mts
CHANGED
|
@@ -24,6 +24,10 @@ declare const findUserByEmail: (email: string, options: ModuleOptions) => Promis
|
|
|
24
24
|
* Hashes the new password before storing.
|
|
25
25
|
*/
|
|
26
26
|
declare const updateUserPassword: (email: string, newPassword: string, options: ModuleOptions) => Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Gets the current user from an authentication token.
|
|
29
|
+
*/
|
|
30
|
+
declare const getCurrentUserFromToken: (token: string, options: ModuleOptions) => Promise<User | null>;
|
|
27
31
|
|
|
28
32
|
declare const createUsersTable: (options: ModuleOptions) => Promise<void>;
|
|
29
33
|
|
|
@@ -60,5 +64,5 @@ declare const validatePassword: (password: string, options?: PasswordValidationO
|
|
|
60
64
|
declare const getPasswordStrengthColor: (strength: "weak" | "medium" | "strong") => string;
|
|
61
65
|
declare const getPasswordStrengthText: (strength: "weak" | "medium" | "strong") => string;
|
|
62
66
|
|
|
63
|
-
export { checkTableExists, createMigrationsTable, createPasswordResetTokensTable, createPersonalAccessTokensTable, createUser, createUsersTable, findUserByEmail, getPasswordStrengthColor, getPasswordStrengthText, getPasswordValidationOptions, runMigrations, updateUserPassword, useDb, validatePassword };
|
|
67
|
+
export { checkTableExists, createMigrationsTable, createPasswordResetTokensTable, createPersonalAccessTokensTable, createUser, createUsersTable, findUserByEmail, getCurrentUserFromToken, getPasswordStrengthColor, getPasswordStrengthText, getPasswordValidationOptions, runMigrations, updateUserPassword, useDb, validatePassword };
|
|
64
68
|
export type { PasswordValidationOptions, PasswordValidationResult };
|
package/dist/utils.d.ts
CHANGED
|
@@ -24,6 +24,10 @@ declare const findUserByEmail: (email: string, options: ModuleOptions) => Promis
|
|
|
24
24
|
* Hashes the new password before storing.
|
|
25
25
|
*/
|
|
26
26
|
declare const updateUserPassword: (email: string, newPassword: string, options: ModuleOptions) => Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Gets the current user from an authentication token.
|
|
29
|
+
*/
|
|
30
|
+
declare const getCurrentUserFromToken: (token: string, options: ModuleOptions) => Promise<User | null>;
|
|
27
31
|
|
|
28
32
|
declare const createUsersTable: (options: ModuleOptions) => Promise<void>;
|
|
29
33
|
|
|
@@ -60,5 +64,5 @@ declare const validatePassword: (password: string, options?: PasswordValidationO
|
|
|
60
64
|
declare const getPasswordStrengthColor: (strength: "weak" | "medium" | "strong") => string;
|
|
61
65
|
declare const getPasswordStrengthText: (strength: "weak" | "medium" | "strong") => string;
|
|
62
66
|
|
|
63
|
-
export { checkTableExists, createMigrationsTable, createPasswordResetTokensTable, createPersonalAccessTokensTable, createUser, createUsersTable, findUserByEmail, getPasswordStrengthColor, getPasswordStrengthText, getPasswordValidationOptions, runMigrations, updateUserPassword, useDb, validatePassword };
|
|
67
|
+
export { checkTableExists, createMigrationsTable, createPasswordResetTokensTable, createPersonalAccessTokensTable, createUser, createUsersTable, findUserByEmail, getCurrentUserFromToken, getPasswordStrengthColor, getPasswordStrengthText, getPasswordValidationOptions, runMigrations, updateUserPassword, useDb, validatePassword };
|
|
64
68
|
export type { PasswordValidationOptions, PasswordValidationResult };
|
package/dist/utils.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { c as checkTableExists,
|
|
1
|
+
export { c as checkTableExists, i as createMigrationsTable, h as createPasswordResetTokensTable, e as createPersonalAccessTokensTable, a as createUser, d as createUsersTable, f as findUserByEmail, g as getCurrentUserFromToken, k as getPasswordStrengthColor, l as getPasswordStrengthText, j as getPasswordValidationOptions, r as runMigrations, b as updateUserPassword, u as useDb, v as validatePassword } from './shared/nuxt-users.C_UkhLJ9.mjs';
|
|
2
2
|
import 'bcrypt';
|
|
3
3
|
import 'db0';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-users",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "A comprehensive user management module for Nuxt 3 applications with authentication, database support, and CLI tools",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nuxt",
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
"eslint": "^9.30.1",
|
|
115
115
|
"nuxt": "^3.17.6",
|
|
116
116
|
"tsx": "^4.20.3",
|
|
117
|
-
"typescript": "~5.
|
|
117
|
+
"typescript": "~5.9.0",
|
|
118
118
|
"unbuild": "^3.0.0",
|
|
119
119
|
"vitepress": "^1.6.3",
|
|
120
120
|
"vitest": "^3.2.4",
|
/package/dist/runtime/server/api/{profile/update-password.post.d.ts → update-password.post.d.ts}
RENAMED
|
File without changes
|