nuxt-users 1.24.0 → 1.26.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/CHANGELOG.md +34 -0
- package/dist/module.d.mts +1 -1
- package/dist/module.d.ts +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +4 -2
- package/dist/runtime/components/NUsersUserForm.vue +2 -1
- package/dist/runtime/components/NUsersUserForm.vue.d.ts +2 -0
- package/dist/runtime/server/api/nuxt-users/me.patch.js +3 -0
- package/dist/runtime/server/utils/user.d.ts +3 -0
- package/dist/runtime/server/utils/user.js +9 -3
- package/dist/shared/{nuxt-users.CqP-FK1T.d.mts → nuxt-users.CydOpwYH.d.mts} +8 -0
- package/dist/shared/{nuxt-users.CqP-FK1T.d.ts → nuxt-users.CydOpwYH.d.ts} +8 -0
- package/dist/utils.d.mts +1 -1
- package/dist/utils.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,40 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
## v1.26.0
|
|
5
|
+
|
|
6
|
+
[compare changes](https://github.com/rrd108/nuxt-users/compare/v1.25.0...v1.26.0)
|
|
7
|
+
|
|
8
|
+
### 🚀 Enhancements
|
|
9
|
+
|
|
10
|
+
- Use soft delete by default ([5c9f0da](https://github.com/rrd108/nuxt-users/commit/5c9f0da))
|
|
11
|
+
- Emit error ([0818b80](https://github.com/rrd108/nuxt-users/commit/0818b80))
|
|
12
|
+
|
|
13
|
+
### 🏡 Chore
|
|
14
|
+
|
|
15
|
+
- **release:** V1.25.0 ([20be66a](https://github.com/rrd108/nuxt-users/commit/20be66a))
|
|
16
|
+
|
|
17
|
+
### ❤️ Contributors
|
|
18
|
+
|
|
19
|
+
- Rrd108 ([@rrd108](https://github.com/rrd108))
|
|
20
|
+
|
|
21
|
+
## v1.25.0
|
|
22
|
+
|
|
23
|
+
[compare changes](https://github.com/rrd108/nuxt-users/compare/v1.24.0...v1.25.0)
|
|
24
|
+
|
|
25
|
+
### 🚀 Enhancements
|
|
26
|
+
|
|
27
|
+
- Remove user form view on deletion ([2066238](https://github.com/rrd108/nuxt-users/commit/2066238))
|
|
28
|
+
- Use soft delete by default ([5c9f0da](https://github.com/rrd108/nuxt-users/commit/5c9f0da))
|
|
29
|
+
|
|
30
|
+
### 🏡 Chore
|
|
31
|
+
|
|
32
|
+
- **release:** V1.24.0 ([ca9ee73](https://github.com/rrd108/nuxt-users/commit/ca9ee73))
|
|
33
|
+
|
|
34
|
+
### ❤️ Contributors
|
|
35
|
+
|
|
36
|
+
- Rrd108 ([@rrd108](https://github.com/rrd108))
|
|
37
|
+
|
|
4
38
|
## v1.24.0
|
|
5
39
|
|
|
6
40
|
[compare changes](https://github.com/rrd108/nuxt-users/compare/v1.23.1...v1.24.0)
|
package/dist/module.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
-
import { R as RuntimeModuleOptions, M as ModuleOptions } from './shared/nuxt-users.
|
|
2
|
+
import { R as RuntimeModuleOptions, M as ModuleOptions } from './shared/nuxt-users.CydOpwYH.mjs';
|
|
3
3
|
export * from '../dist/runtime/server/internal/index.js';
|
|
4
4
|
|
|
5
5
|
declare const defaultOptions: ModuleOptions;
|
package/dist/module.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
-
import { R as RuntimeModuleOptions, M as ModuleOptions } from './shared/nuxt-users.
|
|
2
|
+
import { R as RuntimeModuleOptions, M as ModuleOptions } from './shared/nuxt-users.CydOpwYH.js';
|
|
3
3
|
export * from '../dist/runtime/server/internal/index.js';
|
|
4
4
|
|
|
5
5
|
declare const defaultOptions: ModuleOptions;
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -46,7 +46,8 @@ const defaultOptions = {
|
|
|
46
46
|
requireNumbers: true,
|
|
47
47
|
requireSpecialChars: true,
|
|
48
48
|
preventCommonPasswords: true
|
|
49
|
-
}
|
|
49
|
+
},
|
|
50
|
+
hardDelete: false
|
|
50
51
|
};
|
|
51
52
|
const module = defineNuxtModule({
|
|
52
53
|
meta: {
|
|
@@ -72,7 +73,8 @@ const module = defineNuxtModule({
|
|
|
72
73
|
whitelist: [...defaultOptions.auth?.whitelist || [], ...options.auth?.whitelist || []],
|
|
73
74
|
tokenExpiration: options.auth?.tokenExpiration || defaultOptions.auth.tokenExpiration,
|
|
74
75
|
permissions: options.auth?.permissions || defaultOptions.auth.permissions
|
|
75
|
-
}
|
|
76
|
+
},
|
|
77
|
+
hardDelete: options.hardDelete ?? defaultOptions.hardDelete
|
|
76
78
|
};
|
|
77
79
|
nuxt.options.runtimeConfig.public = nuxt.options.runtimeConfig.public || {};
|
|
78
80
|
nuxt.options.runtimeConfig.public.nuxtUsers = {
|
|
@@ -5,7 +5,7 @@ import { useRuntimeConfig } from "#imports";
|
|
|
5
5
|
const props = defineProps({
|
|
6
6
|
user: { type: null, required: false }
|
|
7
7
|
});
|
|
8
|
-
const emit = defineEmits(["submit", "cancel"]);
|
|
8
|
+
const emit = defineEmits(["submit", "cancel", "error"]);
|
|
9
9
|
const emptyFormData = {
|
|
10
10
|
name: "",
|
|
11
11
|
email: "",
|
|
@@ -68,6 +68,7 @@ const handleSubmit = async () => {
|
|
|
68
68
|
formData.value = { ...emptyFormData };
|
|
69
69
|
} catch (error) {
|
|
70
70
|
console.error("Failed to save user:", error);
|
|
71
|
+
emit("error", error);
|
|
71
72
|
}
|
|
72
73
|
};
|
|
73
74
|
</script>
|
|
@@ -4,9 +4,11 @@ interface Props {
|
|
|
4
4
|
}
|
|
5
5
|
declare const _default: import("vue").DefineComponent<Props, void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
6
6
|
cancel: () => any;
|
|
7
|
+
error: (error: unknown) => any;
|
|
7
8
|
submit: (userData: User) => any;
|
|
8
9
|
}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
|
|
9
10
|
onCancel?: (() => any) | undefined;
|
|
11
|
+
onError?: ((error: unknown) => any) | undefined;
|
|
10
12
|
onSubmit?: ((userData: User) => any) | undefined;
|
|
11
13
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
12
14
|
export default _default;
|
|
@@ -25,6 +25,9 @@ export declare const findUserById: <T extends boolean = false>(id: number, optio
|
|
|
25
25
|
export declare const updateUser: (id: number, userData: Partial<User>, options: ModuleOptions) => Promise<UserWithoutPassword>;
|
|
26
26
|
/**
|
|
27
27
|
* Deletes a user by their ID.
|
|
28
|
+
* By default performs soft delete (sets active to false).
|
|
29
|
+
* If hardDelete option is true, performs hard delete (removes from database).
|
|
30
|
+
* In both cases, user tokens are revoked.
|
|
28
31
|
*/
|
|
29
32
|
export declare const deleteUser: (id: number, options: ModuleOptions) => Promise<void>;
|
|
30
33
|
/**
|
|
@@ -96,10 +96,16 @@ export const updateUser = async (id, userData, options) => {
|
|
|
96
96
|
export const deleteUser = async (id, options) => {
|
|
97
97
|
const db = await useDb(options);
|
|
98
98
|
const usersTable = options.tables.users;
|
|
99
|
-
const
|
|
100
|
-
if (
|
|
101
|
-
throw new Error("User not found
|
|
99
|
+
const userExists = await db.sql`SELECT id FROM {${usersTable}} WHERE id = ${id}`;
|
|
100
|
+
if (userExists.rows.length === 0) {
|
|
101
|
+
throw new Error("User not found.");
|
|
102
102
|
}
|
|
103
|
+
await revokeUserTokens(id, options);
|
|
104
|
+
if (options.hardDelete) {
|
|
105
|
+
await db.sql`DELETE FROM {${usersTable}} WHERE id = ${id}`;
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
await db.sql`UPDATE {${usersTable}} SET active = false, updated_at = CURRENT_TIMESTAMP WHERE id = ${id}`;
|
|
103
109
|
};
|
|
104
110
|
export const updateUserPassword = async (email, newPassword, options) => {
|
|
105
111
|
const db = await useDb(options);
|
|
@@ -100,6 +100,13 @@ interface RuntimeModuleOptions {
|
|
|
100
100
|
*/
|
|
101
101
|
preventCommonPasswords?: boolean;
|
|
102
102
|
};
|
|
103
|
+
/**
|
|
104
|
+
* Enable hard delete for user deletion
|
|
105
|
+
* When false (default), users are soft deleted (active set to false)
|
|
106
|
+
* When true, users are permanently deleted from database
|
|
107
|
+
* @default false
|
|
108
|
+
*/
|
|
109
|
+
hardDelete?: boolean;
|
|
103
110
|
}
|
|
104
111
|
interface ModuleOptions {
|
|
105
112
|
connector: {
|
|
@@ -128,6 +135,7 @@ interface ModuleOptions {
|
|
|
128
135
|
requireSpecialChars: boolean;
|
|
129
136
|
preventCommonPasswords: boolean;
|
|
130
137
|
};
|
|
138
|
+
hardDelete: boolean;
|
|
131
139
|
}
|
|
132
140
|
interface MailerOptions {
|
|
133
141
|
host: string;
|
|
@@ -100,6 +100,13 @@ interface RuntimeModuleOptions {
|
|
|
100
100
|
*/
|
|
101
101
|
preventCommonPasswords?: boolean;
|
|
102
102
|
};
|
|
103
|
+
/**
|
|
104
|
+
* Enable hard delete for user deletion
|
|
105
|
+
* When false (default), users are soft deleted (active set to false)
|
|
106
|
+
* When true, users are permanently deleted from database
|
|
107
|
+
* @default false
|
|
108
|
+
*/
|
|
109
|
+
hardDelete?: boolean;
|
|
103
110
|
}
|
|
104
111
|
interface ModuleOptions {
|
|
105
112
|
connector: {
|
|
@@ -128,6 +135,7 @@ interface ModuleOptions {
|
|
|
128
135
|
requireSpecialChars: boolean;
|
|
129
136
|
preventCommonPasswords: boolean;
|
|
130
137
|
};
|
|
138
|
+
hardDelete: boolean;
|
|
131
139
|
}
|
|
132
140
|
interface MailerOptions {
|
|
133
141
|
host: string;
|
package/dist/utils.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { g as DatabaseConfig, f as DatabaseType, D as DisplayFieldsProps, L as LoginFormData, c as LoginFormProps, M as ModuleOptions, b as PasswordResetToken, e as Permission, P as PersonalAccessToken, d as ResetPasswordFormProps, R as RuntimeModuleOptions, U as User, a as UserWithoutPassword, h as defaultDisplayFields, i as defaultFieldLabels } from './shared/nuxt-users.
|
|
1
|
+
export { g as DatabaseConfig, f as DatabaseType, D as DisplayFieldsProps, L as LoginFormData, c as LoginFormProps, M as ModuleOptions, b as PasswordResetToken, e as Permission, P as PersonalAccessToken, d as ResetPasswordFormProps, R as RuntimeModuleOptions, U as User, a as UserWithoutPassword, h as defaultDisplayFields, i as defaultFieldLabels } from './shared/nuxt-users.CydOpwYH.mjs';
|
|
2
2
|
|
|
3
3
|
interface PasswordValidationResult {
|
|
4
4
|
isValid: boolean;
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { g as DatabaseConfig, f as DatabaseType, D as DisplayFieldsProps, L as LoginFormData, c as LoginFormProps, M as ModuleOptions, b as PasswordResetToken, e as Permission, P as PersonalAccessToken, d as ResetPasswordFormProps, R as RuntimeModuleOptions, U as User, a as UserWithoutPassword, h as defaultDisplayFields, i as defaultFieldLabels } from './shared/nuxt-users.
|
|
1
|
+
export { g as DatabaseConfig, f as DatabaseType, D as DisplayFieldsProps, L as LoginFormData, c as LoginFormProps, M as ModuleOptions, b as PasswordResetToken, e as Permission, P as PersonalAccessToken, d as ResetPasswordFormProps, R as RuntimeModuleOptions, U as User, a as UserWithoutPassword, h as defaultDisplayFields, i as defaultFieldLabels } from './shared/nuxt-users.CydOpwYH.js';
|
|
2
2
|
|
|
3
3
|
interface PasswordValidationResult {
|
|
4
4
|
isValid: boolean;
|
package/package.json
CHANGED