nuxt-users 1.17.3 → 1.21.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 +131 -0
- package/dist/module.d.mts +1 -1
- package/dist/module.d.ts +1 -1
- package/dist/module.json +1 -1
- package/dist/runtime/components/NUsersList.vue.d.ts +1 -1
- package/dist/runtime/components/NUsersLoginForm.vue.d.ts +1 -1
- package/dist/runtime/components/NUsersResetPasswordForm.vue +82 -10
- package/dist/runtime/components/NUsersResetPasswordForm.vue.d.ts +1 -1
- package/dist/runtime/components/NUsersUserCard.vue.d.ts +1 -1
- package/dist/runtime/components/NUsersUserForm.vue.d.ts +1 -1
- package/dist/runtime/composables/useAuthentication.d.ts +1 -1
- package/dist/runtime/composables/usePasswordValidation.d.ts +1 -1
- package/dist/runtime/composables/usePasswordValidation.js +1 -1
- package/dist/runtime/server/api/nuxt-users/[id].get.d.ts +1 -1
- package/dist/runtime/server/api/nuxt-users/[id].patch.d.ts +1 -1
- package/dist/runtime/server/api/nuxt-users/index.post.d.ts +1 -1
- package/dist/runtime/server/api/nuxt-users/me.get.d.ts +1 -1
- package/dist/runtime/server/api/nuxt-users/me.patch.d.ts +1 -1
- package/dist/runtime/server/api/nuxt-users/password/index.patch.js +2 -2
- package/dist/runtime/server/api/nuxt-users/password/reset.post.js +1 -1
- package/dist/runtime/server/api/nuxt-users/session/index.delete.js +1 -1
- package/dist/runtime/server/api/nuxt-users/session/index.post.js +1 -1
- package/dist/runtime/server/composables/useNuxtUsersDatabase.d.ts +3 -3
- package/dist/runtime/server/composables/useServerAuth.d.ts +1 -1
- package/dist/runtime/server/services/password.d.ts +1 -1
- package/dist/runtime/server/utils/add-active-to-users.d.ts +1 -1
- package/dist/runtime/server/utils/create-migrations-table.d.ts +1 -1
- package/dist/runtime/server/utils/create-password-reset-tokens-table.d.ts +1 -1
- package/dist/runtime/server/utils/create-personal-access-tokens-table.d.ts +1 -1
- package/dist/runtime/server/utils/create-users-table.d.ts +1 -1
- package/dist/runtime/server/utils/db.d.ts +4 -2
- package/dist/runtime/server/utils/db.js +16 -1
- package/dist/runtime/server/utils/migrate.d.ts +1 -1
- package/dist/runtime/server/utils/user.d.ts +1 -1
- package/dist/runtime/server/utils/user.js +1 -1
- package/dist/runtime/utils/imports.d.ts +2 -0
- package/dist/runtime/utils/imports.js +2 -0
- package/dist/runtime/utils/permissions.d.ts +1 -1
- package/dist/shared/{nuxt-users.B8X7pDsj.d.mts → nuxt-users.xWt1KUwn.d.mts} +4 -2
- package/dist/shared/{nuxt-users.B8X7pDsj.d.ts → nuxt-users.xWt1KUwn.d.ts} +4 -2
- package/dist/utils.d.mts +1 -1
- package/dist/utils.d.ts +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,137 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
## v1.21.0
|
|
5
|
+
|
|
6
|
+
[compare changes](https://github.com/rrd108/nuxt-users/compare/v1.18.0...v1.21.0)
|
|
7
|
+
|
|
8
|
+
### 🚀 Enhancements
|
|
9
|
+
|
|
10
|
+
- Handle forgot password ([e9a90b6](https://github.com/rrd108/nuxt-users/commit/e9a90b6))
|
|
11
|
+
|
|
12
|
+
### 🩹 Fixes
|
|
13
|
+
|
|
14
|
+
- Updates build command to include stub generation ([c36ac34](https://github.com/rrd108/nuxt-users/commit/c36ac34))
|
|
15
|
+
- Improves database connection handling ([3982c0c](https://github.com/rrd108/nuxt-users/commit/3982c0c))
|
|
16
|
+
- Imports setup ([dd8e8df](https://github.com/rrd108/nuxt-users/commit/dd8e8df))
|
|
17
|
+
|
|
18
|
+
### 💅 Refactors
|
|
19
|
+
|
|
20
|
+
- Imports ([c5723f9](https://github.com/rrd108/nuxt-users/commit/c5723f9))
|
|
21
|
+
- Utils directory and fixes import paths ([7dd48f6](https://github.com/rrd108/nuxt-users/commit/7dd48f6))
|
|
22
|
+
|
|
23
|
+
### 📖 Documentation
|
|
24
|
+
|
|
25
|
+
- Reorganizes structure ([bd710cd](https://github.com/rrd108/nuxt-users/commit/bd710cd))
|
|
26
|
+
|
|
27
|
+
### 🏡 Chore
|
|
28
|
+
|
|
29
|
+
- **release:** V1.18.0 ([9f1cdfb](https://github.com/rrd108/nuxt-users/commit/9f1cdfb))
|
|
30
|
+
- **release:** V1.19.0 ([ac2d375](https://github.com/rrd108/nuxt-users/commit/ac2d375))
|
|
31
|
+
- **release:** V1.20.0 ([1186e63](https://github.com/rrd108/nuxt-users/commit/1186e63))
|
|
32
|
+
- Remove unused file ([14bea18](https://github.com/rrd108/nuxt-users/commit/14bea18))
|
|
33
|
+
- Lint fix ([a11887b](https://github.com/rrd108/nuxt-users/commit/a11887b))
|
|
34
|
+
|
|
35
|
+
### ✅ Tests
|
|
36
|
+
|
|
37
|
+
- **ci:** Fix postgres fail on ([4a1a092](https://github.com/rrd108/nuxt-users/commit/4a1a092))
|
|
38
|
+
|
|
39
|
+
### ❤️ Contributors
|
|
40
|
+
|
|
41
|
+
- Rrd108 ([@rrd108](https://github.com/rrd108))
|
|
42
|
+
|
|
43
|
+
## v1.20.0
|
|
44
|
+
|
|
45
|
+
[compare changes](https://github.com/rrd108/nuxt-users/compare/v1.18.0...v1.20.0)
|
|
46
|
+
|
|
47
|
+
### 🚀 Enhancements
|
|
48
|
+
|
|
49
|
+
- Handle forgot password ([e9a90b6](https://github.com/rrd108/nuxt-users/commit/e9a90b6))
|
|
50
|
+
|
|
51
|
+
### 🩹 Fixes
|
|
52
|
+
|
|
53
|
+
- Updates build command to include stub generation ([c36ac34](https://github.com/rrd108/nuxt-users/commit/c36ac34))
|
|
54
|
+
|
|
55
|
+
### 💅 Refactors
|
|
56
|
+
|
|
57
|
+
- Imports ([c5723f9](https://github.com/rrd108/nuxt-users/commit/c5723f9))
|
|
58
|
+
- Utils directory and fixes import paths ([7dd48f6](https://github.com/rrd108/nuxt-users/commit/7dd48f6))
|
|
59
|
+
|
|
60
|
+
### 📖 Documentation
|
|
61
|
+
|
|
62
|
+
- Reorganizes structure ([bd710cd](https://github.com/rrd108/nuxt-users/commit/bd710cd))
|
|
63
|
+
|
|
64
|
+
### 🏡 Chore
|
|
65
|
+
|
|
66
|
+
- **release:** V1.18.0 ([9f1cdfb](https://github.com/rrd108/nuxt-users/commit/9f1cdfb))
|
|
67
|
+
- **release:** V1.19.0 ([ac2d375](https://github.com/rrd108/nuxt-users/commit/ac2d375))
|
|
68
|
+
|
|
69
|
+
### ✅ Tests
|
|
70
|
+
|
|
71
|
+
- **ci:** Fix postgres fail on ([4a1a092](https://github.com/rrd108/nuxt-users/commit/4a1a092))
|
|
72
|
+
|
|
73
|
+
### ❤️ Contributors
|
|
74
|
+
|
|
75
|
+
- Rrd108 ([@rrd108](https://github.com/rrd108))
|
|
76
|
+
|
|
77
|
+
## v1.19.0
|
|
78
|
+
|
|
79
|
+
[compare changes](https://github.com/rrd108/nuxt-users/compare/v1.18.0...v1.19.0)
|
|
80
|
+
|
|
81
|
+
### 🚀 Enhancements
|
|
82
|
+
|
|
83
|
+
- Handle forgot password ([e9a90b6](https://github.com/rrd108/nuxt-users/commit/e9a90b6))
|
|
84
|
+
|
|
85
|
+
### 🩹 Fixes
|
|
86
|
+
|
|
87
|
+
- Updates build command to include stub generation ([c36ac34](https://github.com/rrd108/nuxt-users/commit/c36ac34))
|
|
88
|
+
|
|
89
|
+
### 💅 Refactors
|
|
90
|
+
|
|
91
|
+
- Imports ([c5723f9](https://github.com/rrd108/nuxt-users/commit/c5723f9))
|
|
92
|
+
- Utils directory and fixes import paths ([7dd48f6](https://github.com/rrd108/nuxt-users/commit/7dd48f6))
|
|
93
|
+
|
|
94
|
+
### 📖 Documentation
|
|
95
|
+
|
|
96
|
+
- Reorganizes structure ([bd710cd](https://github.com/rrd108/nuxt-users/commit/bd710cd))
|
|
97
|
+
|
|
98
|
+
### 🏡 Chore
|
|
99
|
+
|
|
100
|
+
- **release:** V1.18.0 ([9f1cdfb](https://github.com/rrd108/nuxt-users/commit/9f1cdfb))
|
|
101
|
+
|
|
102
|
+
### ❤️ Contributors
|
|
103
|
+
|
|
104
|
+
- Rrd108 ([@rrd108](https://github.com/rrd108))
|
|
105
|
+
|
|
106
|
+
## v1.18.0
|
|
107
|
+
|
|
108
|
+
[compare changes](https://github.com/rrd108/nuxt-users/compare/v1.17.3...v1.18.0)
|
|
109
|
+
|
|
110
|
+
### 🚀 Enhancements
|
|
111
|
+
|
|
112
|
+
- Handle forgot password ([e9a90b6](https://github.com/rrd108/nuxt-users/commit/e9a90b6))
|
|
113
|
+
|
|
114
|
+
### 🩹 Fixes
|
|
115
|
+
|
|
116
|
+
- Cli version ([586194f](https://github.com/rrd108/nuxt-users/commit/586194f))
|
|
117
|
+
- Use runtime config for password reset link ([f462f64](https://github.com/rrd108/nuxt-users/commit/f462f64))
|
|
118
|
+
|
|
119
|
+
### 💅 Refactors
|
|
120
|
+
|
|
121
|
+
- Imports ([c5723f9](https://github.com/rrd108/nuxt-users/commit/c5723f9))
|
|
122
|
+
|
|
123
|
+
### 📖 Documentation
|
|
124
|
+
|
|
125
|
+
- Reorganizes structure ([bd710cd](https://github.com/rrd108/nuxt-users/commit/bd710cd))
|
|
126
|
+
|
|
127
|
+
### 🏡 Chore
|
|
128
|
+
|
|
129
|
+
- **release:** V1.17.3 ([29f0dbc](https://github.com/rrd108/nuxt-users/commit/29f0dbc))
|
|
130
|
+
|
|
131
|
+
### ❤️ Contributors
|
|
132
|
+
|
|
133
|
+
- Rrd108 ([@rrd108](https://github.com/rrd108))
|
|
134
|
+
|
|
4
135
|
## v1.17.3
|
|
5
136
|
|
|
6
137
|
[compare changes](https://github.com/rrd108/nuxt-users/compare/v1.17.2...v1.17.3)
|
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.xWt1KUwn.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.xWt1KUwn.js';
|
|
3
3
|
export * from '../dist/runtime/server/internal/index.js';
|
|
4
4
|
|
|
5
5
|
declare const defaultOptions: ModuleOptions;
|
package/dist/module.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { LoginFormData, LoginFormProps, UserWithoutPassword } from '
|
|
1
|
+
import type { LoginFormData, LoginFormProps, UserWithoutPassword } from 'nuxt-users/utils';
|
|
2
2
|
declare var __VLS_1: {}, __VLS_3: {}, __VLS_5: {}, __VLS_7: {}, __VLS_9: {}, __VLS_11: {}, __VLS_13: {
|
|
3
3
|
message: string;
|
|
4
4
|
}, __VLS_15: {
|
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { ref, watch } from "vue";
|
|
2
|
+
import { ref, watch, computed } from "vue";
|
|
3
3
|
import { usePasswordValidation } from "../composables/usePasswordValidation";
|
|
4
|
-
import { useRuntimeConfig } from "#imports";
|
|
4
|
+
import { useRuntimeConfig, useRoute, useRouter } from "#imports";
|
|
5
5
|
import NUsersPasswordStrengthIndicator from "./NUsersPasswordStrengthIndicator.vue";
|
|
6
6
|
const { public: { nuxtUsers } } = useRuntimeConfig();
|
|
7
7
|
const moduleOptions = nuxtUsers;
|
|
8
8
|
const props = defineProps({
|
|
9
9
|
apiEndpoint: { type: String, required: false },
|
|
10
|
-
updatePasswordEndpoint: { type: String, required: false }
|
|
10
|
+
updatePasswordEndpoint: { type: String, required: false },
|
|
11
|
+
resetPasswordEndpoint: { type: String, required: false },
|
|
12
|
+
redirectTo: { type: String, required: false }
|
|
11
13
|
});
|
|
12
14
|
const emit = defineEmits(["success", "error", "password-error", "password-updated"]);
|
|
15
|
+
const route = useRoute();
|
|
16
|
+
const router = useRouter();
|
|
13
17
|
const isPasswordLoading = ref(false);
|
|
14
18
|
const passwordError = ref("");
|
|
15
19
|
const passwordSuccess = ref("");
|
|
20
|
+
const isPasswordReset = computed(() => {
|
|
21
|
+
return route.query.token && route.query.email;
|
|
22
|
+
});
|
|
23
|
+
const resetToken = computed(() => route.query.token);
|
|
24
|
+
const resetEmail = computed(() => route.query.email);
|
|
16
25
|
const passwordForm = ref({
|
|
17
26
|
currentPassword: "",
|
|
18
27
|
newPassword: "",
|
|
@@ -50,16 +59,75 @@ const updatePassword = async () => {
|
|
|
50
59
|
isPasswordLoading.value = false;
|
|
51
60
|
}
|
|
52
61
|
};
|
|
62
|
+
const resetPassword = async () => {
|
|
63
|
+
if (!resetToken.value || !resetEmail.value) {
|
|
64
|
+
passwordError.value = "Missing reset token or email. Please use the link from your email.";
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (passwordForm.value.newPassword !== passwordForm.value.newPasswordConfirmation) {
|
|
68
|
+
passwordError.value = "Passwords do not match";
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
isPasswordLoading.value = true;
|
|
72
|
+
passwordError.value = "";
|
|
73
|
+
passwordSuccess.value = "";
|
|
74
|
+
try {
|
|
75
|
+
await $fetch(props.resetPasswordEndpoint || nuxtUsers.apiBasePath + "/password/reset", {
|
|
76
|
+
method: "POST",
|
|
77
|
+
body: {
|
|
78
|
+
token: resetToken.value,
|
|
79
|
+
email: resetEmail.value,
|
|
80
|
+
password: passwordForm.value.newPassword,
|
|
81
|
+
password_confirmation: passwordForm.value.newPasswordConfirmation
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
passwordSuccess.value = "Password reset successfully. You can now log in with your new password.";
|
|
85
|
+
emit("password-updated");
|
|
86
|
+
passwordForm.value = {
|
|
87
|
+
currentPassword: "",
|
|
88
|
+
newPassword: "",
|
|
89
|
+
newPasswordConfirmation: ""
|
|
90
|
+
};
|
|
91
|
+
setTimeout(() => {
|
|
92
|
+
router.push(props.redirectTo || "/login");
|
|
93
|
+
}, 2e3);
|
|
94
|
+
} catch (err) {
|
|
95
|
+
const errorMessage = err && typeof err === "object" && "data" in err && err.data && typeof err.data === "object" && "statusMessage" in err.data ? String(err.data.statusMessage) : err instanceof Error ? err.message : "Failed to reset password";
|
|
96
|
+
passwordError.value = errorMessage;
|
|
97
|
+
emit("password-error", errorMessage);
|
|
98
|
+
} finally {
|
|
99
|
+
isPasswordLoading.value = false;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
const handleSubmit = () => {
|
|
103
|
+
if (isPasswordReset.value) {
|
|
104
|
+
resetPassword();
|
|
105
|
+
} else {
|
|
106
|
+
updatePassword();
|
|
107
|
+
}
|
|
108
|
+
};
|
|
53
109
|
</script>
|
|
54
110
|
|
|
55
111
|
<template>
|
|
56
112
|
<div class="n-users-section">
|
|
57
113
|
<h2 class="n-users-section-header">
|
|
58
|
-
Change Password
|
|
114
|
+
{{ isPasswordReset ? "Reset Password" : "Change Password" }}
|
|
59
115
|
</h2>
|
|
60
116
|
|
|
61
|
-
<
|
|
62
|
-
|
|
117
|
+
<div
|
|
118
|
+
v-if="isPasswordReset"
|
|
119
|
+
class="n-users-info-message"
|
|
120
|
+
>
|
|
121
|
+
<p>You are resetting your password using a secure link.</p>
|
|
122
|
+
<p><strong>Email:</strong> {{ resetEmail }}</p>
|
|
123
|
+
</div>
|
|
124
|
+
|
|
125
|
+
<form @submit.prevent="handleSubmit">
|
|
126
|
+
<!-- Current Password field - only show for logged-in users -->
|
|
127
|
+
<div
|
|
128
|
+
v-if="!isPasswordReset"
|
|
129
|
+
class="n-users-form-group"
|
|
130
|
+
>
|
|
63
131
|
<label
|
|
64
132
|
for="currentPassword"
|
|
65
133
|
class="n-users-form-label"
|
|
@@ -78,7 +146,7 @@ const updatePassword = async () => {
|
|
|
78
146
|
<label
|
|
79
147
|
for="newPassword"
|
|
80
148
|
class="n-users-form-label"
|
|
81
|
-
>New Password</label>
|
|
149
|
+
>{{ isPasswordReset ? "New Password" : "New Password" }}</label>
|
|
82
150
|
<input
|
|
83
151
|
id="newPassword"
|
|
84
152
|
v-model="passwordForm.newPassword"
|
|
@@ -108,7 +176,7 @@ const updatePassword = async () => {
|
|
|
108
176
|
<label
|
|
109
177
|
for="newPasswordConfirmation"
|
|
110
178
|
class="n-users-form-label"
|
|
111
|
-
>Confirm New Password</label>
|
|
179
|
+
>Confirm {{ isPasswordReset ? "New Password" : "New Password" }}</label>
|
|
112
180
|
<input
|
|
113
181
|
id="newPasswordConfirmation"
|
|
114
182
|
v-model="passwordForm.newPasswordConfirmation"
|
|
@@ -138,8 +206,12 @@ const updatePassword = async () => {
|
|
|
138
206
|
class="n-users-btn n-users-btn-primary"
|
|
139
207
|
:disabled="isPasswordLoading"
|
|
140
208
|
>
|
|
141
|
-
<span v-if="isPasswordLoading">
|
|
142
|
-
|
|
209
|
+
<span v-if="isPasswordLoading">
|
|
210
|
+
{{ isPasswordReset ? "Resetting..." : "Updating..." }}
|
|
211
|
+
</span>
|
|
212
|
+
<span v-else>
|
|
213
|
+
{{ isPasswordReset ? "Reset Password" : "Update Password" }}
|
|
214
|
+
</span>
|
|
143
215
|
</button>
|
|
144
216
|
</form>
|
|
145
217
|
</div>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { UserWithoutPassword, ResetPasswordFormProps } from '
|
|
1
|
+
import type { UserWithoutPassword, ResetPasswordFormProps } from 'nuxt-users/utils';
|
|
2
2
|
declare const _default: import("vue").DefineComponent<ResetPasswordFormProps, void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
3
3
|
error: (error: string) => any;
|
|
4
4
|
success: (user: UserWithoutPassword) => any;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type PasswordValidationResult, type PasswordValidationOptions } from '../../utils/index.js';
|
|
2
|
-
import type { RuntimeModuleOptions } from '
|
|
2
|
+
import type { RuntimeModuleOptions } from 'nuxt-users/utils';
|
|
3
3
|
export declare const usePasswordValidation: (moduleOptions?: RuntimeModuleOptions, options?: PasswordValidationOptions) => {
|
|
4
4
|
password: import("vue").Ref<string, string>;
|
|
5
5
|
validationResult: import("vue").Ref<{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ref, computed } from "vue";
|
|
2
|
-
import { validatePassword, getPasswordValidationOptions, getPasswordStrengthColor, getPasswordStrengthText } from "../../utils
|
|
2
|
+
import { validatePassword, getPasswordValidationOptions, getPasswordStrengthColor, getPasswordStrengthText } from "../../utils";
|
|
3
3
|
export const usePasswordValidation = (moduleOptions, options) => {
|
|
4
4
|
const passwordOptions = getPasswordValidationOptions(moduleOptions);
|
|
5
5
|
const finalOptions = { ...passwordOptions, ...options };
|
|
@@ -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 "../../../utils/
|
|
5
|
-
import { validatePassword, getPasswordValidationOptions } from "../../../../../utils
|
|
4
|
+
import { getCurrentUserFromToken, updateUserPassword } from "../../../utils/user.js";
|
|
5
|
+
import { validatePassword, getPasswordValidationOptions } from "../../../../../utils";
|
|
6
6
|
export default defineEventHandler(async (event) => {
|
|
7
7
|
const { nuxtUsers } = useRuntimeConfig();
|
|
8
8
|
const options = nuxtUsers;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineEventHandler, readBody, createError, H3Error } from "h3";
|
|
2
2
|
import { resetPassword } from "../../../services/password.js";
|
|
3
3
|
import { useRuntimeConfig } from "#imports";
|
|
4
|
-
import { validatePassword, getPasswordValidationOptions } from "../../../../../utils
|
|
4
|
+
import { validatePassword, getPasswordValidationOptions } from "../../../../../utils";
|
|
5
5
|
export default defineEventHandler(async (event) => {
|
|
6
6
|
const body = await readBody(event);
|
|
7
7
|
const { token, email, password, password_confirmation } = body;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineEventHandler, getCookie, setCookie } from "h3";
|
|
2
2
|
import { useRuntimeConfig } from "#imports";
|
|
3
|
-
import { useDb } from "../../../utils/
|
|
3
|
+
import { useDb } from "../../../utils/db.js";
|
|
4
4
|
export default defineEventHandler(async (event) => {
|
|
5
5
|
const { nuxtUsers } = useRuntimeConfig();
|
|
6
6
|
const options = nuxtUsers;
|
|
@@ -2,7 +2,7 @@ import { createError, defineEventHandler, readBody, setCookie } from "h3";
|
|
|
2
2
|
import bcrypt from "bcrypt";
|
|
3
3
|
import crypto from "node:crypto";
|
|
4
4
|
import { useRuntimeConfig } from "#imports";
|
|
5
|
-
import { useDb } from "../../../utils/
|
|
5
|
+
import { useDb } from "../../../utils/db.js";
|
|
6
6
|
export default defineEventHandler(async (event) => {
|
|
7
7
|
const body = await readBody(event);
|
|
8
8
|
const { email, password } = body;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const useNuxtUsersDatabase: () => Promise<{
|
|
2
|
-
database: import("db0").Database<import("db0").Connector<
|
|
2
|
+
database: import("db0").Database<import("db0").Connector<unknown>>;
|
|
3
3
|
options: {
|
|
4
4
|
tables: {
|
|
5
5
|
migrations: string;
|
|
@@ -8,8 +8,8 @@ export declare const useNuxtUsersDatabase: () => Promise<{
|
|
|
8
8
|
passwordResetTokens: string;
|
|
9
9
|
};
|
|
10
10
|
connector: {
|
|
11
|
-
name: import("
|
|
12
|
-
options: import("
|
|
11
|
+
name: import("nuxt-users/utils").DatabaseType;
|
|
12
|
+
options: import("nuxt-users/utils").DatabaseConfig;
|
|
13
13
|
};
|
|
14
14
|
};
|
|
15
15
|
}>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ModuleOptions } from '
|
|
1
|
+
import type { ModuleOptions } from 'nuxt-users/utils';
|
|
2
2
|
export declare const addActiveToUsers: (options: ModuleOptions) => Promise<void>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ModuleOptions } from '
|
|
1
|
+
import type { ModuleOptions } from 'nuxt-users/utils';
|
|
2
2
|
export declare const createMigrationsTable: (options: ModuleOptions) => Promise<void>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ModuleOptions } from '
|
|
1
|
+
import type { ModuleOptions } from 'nuxt-users/utils';
|
|
2
2
|
export declare const createPasswordResetTokensTable: (options: ModuleOptions) => Promise<void>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ModuleOptions } from '
|
|
1
|
+
import type { ModuleOptions } from 'nuxt-users/utils';
|
|
2
2
|
export declare const createPersonalAccessTokensTable: (options: ModuleOptions) => Promise<void>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ModuleOptions } from '
|
|
1
|
+
import type { ModuleOptions } from 'nuxt-users/utils';
|
|
2
2
|
export declare const createUsersTable: (options: ModuleOptions) => Promise<void>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Database } from 'db0';
|
|
2
|
+
import type { ModuleOptions } from 'nuxt-users/utils';
|
|
3
|
+
export declare const closeAllDbConnections: () => Promise<void>;
|
|
2
4
|
export declare const getConnector: (name: string) => Promise<typeof import("db0/connectors/mysql2").default | typeof import("db0/connectors/postgresql").default | typeof import("db0/connectors/better-sqlite3").default>;
|
|
3
|
-
export declare const useDb: (options: ModuleOptions) => Promise<
|
|
5
|
+
export declare const useDb: (options: ModuleOptions) => Promise<Database>;
|
|
4
6
|
export declare const checkTableExists: (options: ModuleOptions, tableName: string) => Promise<boolean>;
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import { createDatabase } from "db0";
|
|
2
|
+
const dbCache = /* @__PURE__ */ new Map();
|
|
3
|
+
export const closeAllDbConnections = async () => {
|
|
4
|
+
for (const db of dbCache.values()) {
|
|
5
|
+
if (db && typeof db.disconnect === "function") {
|
|
6
|
+
await db.disconnect();
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
dbCache.clear();
|
|
10
|
+
};
|
|
2
11
|
export const getConnector = async (name) => {
|
|
3
12
|
try {
|
|
4
13
|
switch (name) {
|
|
@@ -22,6 +31,10 @@ export const getConnector = async (name) => {
|
|
|
22
31
|
}
|
|
23
32
|
};
|
|
24
33
|
export const useDb = async (options) => {
|
|
34
|
+
const cacheKey = JSON.stringify(options.connector);
|
|
35
|
+
if (dbCache.has(cacheKey)) {
|
|
36
|
+
return dbCache.get(cacheKey);
|
|
37
|
+
}
|
|
25
38
|
const connectorName = options.connector.name;
|
|
26
39
|
const connector = await getConnector(connectorName);
|
|
27
40
|
const connectorOptions = { ...options.connector.options };
|
|
@@ -29,7 +42,9 @@ export const useDb = async (options) => {
|
|
|
29
42
|
delete connectorOptions.path;
|
|
30
43
|
}
|
|
31
44
|
try {
|
|
32
|
-
|
|
45
|
+
const db = createDatabase(connector(connectorOptions));
|
|
46
|
+
dbCache.set(cacheKey, db);
|
|
47
|
+
return db;
|
|
33
48
|
} catch (error) {
|
|
34
49
|
console.warn(`[Nuxt Users] \u26A0\uFE0F Failed to connect to ${connectorName} database:`, error instanceof Error ? error.message : "Unknown error");
|
|
35
50
|
throw error;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ModuleOptions } from '
|
|
1
|
+
import type { ModuleOptions } from 'nuxt-users/utils';
|
|
2
2
|
export declare const getAppliedMigrations: (options: ModuleOptions) => Promise<string[]>;
|
|
3
3
|
export declare const markMigrationAsApplied: (options: ModuleOptions, migrationName: string) => Promise<void>;
|
|
4
4
|
export declare const runMigrations: (options: ModuleOptions) => Promise<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useDb } from "./db.js";
|
|
2
2
|
import bcrypt from "bcrypt";
|
|
3
|
-
import { validatePassword, getPasswordValidationOptions } from "
|
|
3
|
+
import { validatePassword, getPasswordValidationOptions } from "nuxt-users/utils";
|
|
4
4
|
export const createUser = async (userData, options) => {
|
|
5
5
|
const db = await useDb(options);
|
|
6
6
|
const usersTable = options.tables.users;
|
|
@@ -184,6 +184,8 @@ interface LoginFormProps {
|
|
|
184
184
|
interface ResetPasswordFormProps {
|
|
185
185
|
apiEndpoint?: string;
|
|
186
186
|
updatePasswordEndpoint?: string;
|
|
187
|
+
resetPasswordEndpoint?: string;
|
|
188
|
+
redirectTo?: string;
|
|
187
189
|
}
|
|
188
190
|
interface DisplayFieldsProps {
|
|
189
191
|
displayFields?: string[];
|
|
@@ -201,5 +203,5 @@ declare const defaultFieldLabels: {
|
|
|
201
203
|
last_login_at: string;
|
|
202
204
|
};
|
|
203
205
|
|
|
204
|
-
export { defaultDisplayFields as
|
|
205
|
-
export type { DisplayFieldsProps as D, LoginFormData as L, ModuleOptions as M, PersonalAccessToken as P, RuntimeModuleOptions as R, User as U, UserWithoutPassword as a, PasswordResetToken as b, LoginFormProps as c, ResetPasswordFormProps as d };
|
|
206
|
+
export { defaultDisplayFields as h, defaultFieldLabels as i };
|
|
207
|
+
export type { DisplayFieldsProps as D, LoginFormData as L, ModuleOptions as M, PersonalAccessToken as P, RuntimeModuleOptions as R, User as U, UserWithoutPassword as a, PasswordResetToken as b, LoginFormProps as c, ResetPasswordFormProps as d, Permission as e, DatabaseType as f, DatabaseConfig as g };
|
|
@@ -184,6 +184,8 @@ interface LoginFormProps {
|
|
|
184
184
|
interface ResetPasswordFormProps {
|
|
185
185
|
apiEndpoint?: string;
|
|
186
186
|
updatePasswordEndpoint?: string;
|
|
187
|
+
resetPasswordEndpoint?: string;
|
|
188
|
+
redirectTo?: string;
|
|
187
189
|
}
|
|
188
190
|
interface DisplayFieldsProps {
|
|
189
191
|
displayFields?: string[];
|
|
@@ -201,5 +203,5 @@ declare const defaultFieldLabels: {
|
|
|
201
203
|
last_login_at: string;
|
|
202
204
|
};
|
|
203
205
|
|
|
204
|
-
export { defaultDisplayFields as
|
|
205
|
-
export type { DisplayFieldsProps as D, LoginFormData as L, ModuleOptions as M, PersonalAccessToken as P, RuntimeModuleOptions as R, User as U, UserWithoutPassword as a, PasswordResetToken as b, LoginFormProps as c, ResetPasswordFormProps as d };
|
|
206
|
+
export { defaultDisplayFields as h, defaultFieldLabels as i };
|
|
207
|
+
export type { DisplayFieldsProps as D, LoginFormData as L, ModuleOptions as M, PersonalAccessToken as P, RuntimeModuleOptions as R, User as U, UserWithoutPassword as a, PasswordResetToken as b, LoginFormProps as c, ResetPasswordFormProps as d, Permission as e, DatabaseType as f, DatabaseConfig as g };
|
package/dist/utils.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { D as DisplayFieldsProps, L as LoginFormData, c as LoginFormProps, M as ModuleOptions, b as PasswordResetToken, P as PersonalAccessToken, d as ResetPasswordFormProps, R as RuntimeModuleOptions, U as User, a as UserWithoutPassword,
|
|
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.xWt1KUwn.mjs';
|
|
2
2
|
|
|
3
3
|
interface PasswordValidationResult {
|
|
4
4
|
isValid: boolean;
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { D as DisplayFieldsProps, L as LoginFormData, c as LoginFormProps, M as ModuleOptions, b as PasswordResetToken, P as PersonalAccessToken, d as ResetPasswordFormProps, R as RuntimeModuleOptions, U as User, a as UserWithoutPassword,
|
|
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.xWt1KUwn.js';
|
|
2
2
|
|
|
3
3
|
interface PasswordValidationResult {
|
|
4
4
|
isValid: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-users",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.21.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",
|
|
@@ -66,13 +66,13 @@
|
|
|
66
66
|
"lint": "eslint .",
|
|
67
67
|
"lint:fix": "eslint . --fix",
|
|
68
68
|
"pretest": "node -v | grep -q 'v22' || (echo 'Please use Node.js v22 for testing' && exit 1)",
|
|
69
|
-
"test": "
|
|
70
|
-
"test:watch": "vitest watch",
|
|
69
|
+
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit",
|
|
71
70
|
"test:unit": "./scripts/test-unit.sh",
|
|
72
71
|
"test:sqlite": "./scripts/test-sqlite.sh",
|
|
73
72
|
"test:mysql": "./scripts/test-mysql.sh",
|
|
74
73
|
"test:postgresql": "./scripts/test-postgresql.sh",
|
|
75
|
-
"test
|
|
74
|
+
"test": "yarn test:types && yarn test:unit && yarn test:sqlite && yarn test:mysql && yarn test:postgresql",
|
|
75
|
+
"test:watch": "vitest watch",
|
|
76
76
|
"db:create-users-table": "tsx src/cli/create-users-table.ts",
|
|
77
77
|
"db:create-user": "tsx src/cli/create-user.ts",
|
|
78
78
|
"db:create-personal-access-tokens-table": "tsx src/cli/create-personal-access-tokens-table.ts",
|