nuxt-users 1.6.4 → 1.6.6
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 +50 -0
- package/dist/cli.mjs +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +26 -21
- package/dist/runtime/components/LoginForm.vue +6 -3
- package/dist/runtime/components/LoginForm.vue.d.ts +4 -4
- package/dist/runtime/components/LogoutLink.vue +21 -7
- package/dist/runtime/components/LogoutLink.vue.d.ts +22 -5
- package/dist/runtime/components/PasswordStrengthIndicator.vue +38 -27
- package/dist/runtime/components/ProfileInfo.vue +33 -0
- package/dist/runtime/components/ResetPasswordForm.vue +89 -96
- package/dist/runtime/components/ResetPasswordForm.vue.d.ts +15 -1
- package/dist/runtime/composables/useAuth.d.ts +2 -2
- package/dist/runtime/composables/useAuth.js +2 -2
- package/dist/runtime/composables/usePasswordValidation.d.ts +1 -1
- package/dist/runtime/middleware/auth.client.d.ts +2 -0
- package/dist/runtime/middleware/auth.client.js +20 -0
- package/dist/runtime/plugin.js +1 -46
- package/dist/runtime/server/api/{login.post.js → auth/login.post.js} +1 -1
- package/dist/runtime/server/api/{logout.get.js → auth/logout.get.js} +1 -1
- package/dist/runtime/server/api/auth/reset-password.post.js +0 -3
- package/dist/runtime/server/api/{update-password.post.js → auth/update-password.post.js} +3 -3
- package/dist/runtime/server/api/user/profile.get.d.ts +4 -0
- package/dist/runtime/server/api/{profile.get.js → user/profile.get.js} +2 -3
- package/dist/runtime/server/middleware/auth.server.d.ts +2 -0
- package/dist/runtime/server/middleware/auth.server.js +32 -0
- package/dist/runtime/server/utils/user.d.ts +2 -2
- package/dist/runtime/server/utils/user.js +7 -2
- package/package.json +1 -1
- package/dist/runtime/components/ForgotPasswordForm.vue +0 -77
- package/dist/runtime/components/ProfileForm.vue +0 -240
- package/dist/runtime/components/ProfileForm.vue.d.ts +0 -20
- package/dist/runtime/server/api/profile.get.d.ts +0 -11
- /package/dist/runtime/components/{ForgotPasswordForm.vue.d.ts → ProfileInfo.vue.d.ts} +0 -0
- /package/dist/runtime/server/api/{login.post.d.ts → auth/login.post.d.ts} +0 -0
- /package/dist/runtime/server/api/{logout.get.d.ts → auth/logout.get.d.ts} +0 -0
- /package/dist/runtime/server/api/{update-password.post.d.ts → auth/update-password.post.d.ts} +0 -0
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
<script setup>
|
|
2
|
-
import { ref, onMounted, watch } from "vue";
|
|
3
|
-
import { usePasswordValidation } from "../composables/usePasswordValidation";
|
|
4
|
-
import { useRuntimeConfig } from "#imports";
|
|
5
|
-
import PasswordStrengthIndicator from "./PasswordStrengthIndicator.vue";
|
|
6
|
-
const props = defineProps({
|
|
7
|
-
apiEndpoint: { type: String, required: false, default: "/api/profile" },
|
|
8
|
-
updatePasswordEndpoint: { type: String, required: false, default: "/api/update-password" }
|
|
9
|
-
});
|
|
10
|
-
const emit = defineEmits(["success", "error", "password-error", "password-updated"]);
|
|
11
|
-
const isLoading = ref(false);
|
|
12
|
-
const isPasswordLoading = ref(false);
|
|
13
|
-
const error = ref("");
|
|
14
|
-
const passwordError = ref("");
|
|
15
|
-
const passwordSuccess = ref("");
|
|
16
|
-
const user = ref(null);
|
|
17
|
-
const passwordForm = ref({
|
|
18
|
-
currentPassword: "",
|
|
19
|
-
newPassword: "",
|
|
20
|
-
newPasswordConfirmation: ""
|
|
21
|
-
});
|
|
22
|
-
const { public: { nuxtUsers } } = useRuntimeConfig();
|
|
23
|
-
const moduleOptions = nuxtUsers;
|
|
24
|
-
const passwordValidation = usePasswordValidation(moduleOptions);
|
|
25
|
-
watch(() => passwordForm.value.newPassword, (newPassword) => {
|
|
26
|
-
if (newPassword) {
|
|
27
|
-
passwordValidation.validate(newPassword);
|
|
28
|
-
} else {
|
|
29
|
-
passwordValidation.clearValidation();
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
const loadProfile = async () => {
|
|
33
|
-
isLoading.value = true;
|
|
34
|
-
error.value = "";
|
|
35
|
-
try {
|
|
36
|
-
const response = await $fetch(props.apiEndpoint, {
|
|
37
|
-
method: "GET"
|
|
38
|
-
});
|
|
39
|
-
user.value = response.user;
|
|
40
|
-
emit("success", response.user);
|
|
41
|
-
} catch (err) {
|
|
42
|
-
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 load profile";
|
|
43
|
-
error.value = errorMessage;
|
|
44
|
-
emit("error", errorMessage);
|
|
45
|
-
} finally {
|
|
46
|
-
isLoading.value = false;
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
const updatePassword = async () => {
|
|
50
|
-
isPasswordLoading.value = true;
|
|
51
|
-
passwordError.value = "";
|
|
52
|
-
passwordSuccess.value = "";
|
|
53
|
-
try {
|
|
54
|
-
await $fetch(props.updatePasswordEndpoint, {
|
|
55
|
-
method: "POST",
|
|
56
|
-
body: passwordForm.value
|
|
57
|
-
});
|
|
58
|
-
passwordSuccess.value = "Password updated successfully";
|
|
59
|
-
emit("password-updated");
|
|
60
|
-
passwordForm.value = {
|
|
61
|
-
currentPassword: "",
|
|
62
|
-
newPassword: "",
|
|
63
|
-
newPasswordConfirmation: ""
|
|
64
|
-
};
|
|
65
|
-
} catch (err) {
|
|
66
|
-
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 update password";
|
|
67
|
-
passwordError.value = errorMessage;
|
|
68
|
-
emit("password-error", errorMessage);
|
|
69
|
-
} finally {
|
|
70
|
-
isPasswordLoading.value = false;
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
const formatDate = (dateString) => {
|
|
74
|
-
return new Date(dateString).toLocaleDateString("en-US", {
|
|
75
|
-
year: "numeric",
|
|
76
|
-
month: "long",
|
|
77
|
-
day: "numeric",
|
|
78
|
-
hour: "2-digit",
|
|
79
|
-
minute: "2-digit"
|
|
80
|
-
});
|
|
81
|
-
};
|
|
82
|
-
onMounted(() => {
|
|
83
|
-
loadProfile();
|
|
84
|
-
});
|
|
85
|
-
</script>
|
|
86
|
-
|
|
87
|
-
<template>
|
|
88
|
-
<div class="profile-form">
|
|
89
|
-
<!-- Profile Information Section -->
|
|
90
|
-
<div class="profile-section">
|
|
91
|
-
<h2 class="section-title">
|
|
92
|
-
Profile Information
|
|
93
|
-
</h2>
|
|
94
|
-
|
|
95
|
-
<div
|
|
96
|
-
v-if="isLoading"
|
|
97
|
-
class="loading"
|
|
98
|
-
>
|
|
99
|
-
Loading profile...
|
|
100
|
-
</div>
|
|
101
|
-
|
|
102
|
-
<div
|
|
103
|
-
v-else-if="error"
|
|
104
|
-
class="error-message"
|
|
105
|
-
>
|
|
106
|
-
{{ error }}
|
|
107
|
-
</div>
|
|
108
|
-
|
|
109
|
-
<div
|
|
110
|
-
v-else-if="user"
|
|
111
|
-
class="profile-info"
|
|
112
|
-
>
|
|
113
|
-
<div class="info-row">
|
|
114
|
-
<label class="info-label">Name:</label>
|
|
115
|
-
<span class="info-value">{{ user.name }}</span>
|
|
116
|
-
</div>
|
|
117
|
-
|
|
118
|
-
<div class="info-row">
|
|
119
|
-
<label class="info-label">Email:</label>
|
|
120
|
-
<span class="info-value">{{ user.email }}</span>
|
|
121
|
-
</div>
|
|
122
|
-
|
|
123
|
-
<div class="info-row">
|
|
124
|
-
<label class="info-label">Role:</label>
|
|
125
|
-
<span class="info-value">{{ user.role }}</span>
|
|
126
|
-
</div>
|
|
127
|
-
|
|
128
|
-
<div class="info-row">
|
|
129
|
-
<label class="info-label">Member since:</label>
|
|
130
|
-
<span class="info-value">{{ formatDate(user.created_at) }}</span>
|
|
131
|
-
</div>
|
|
132
|
-
|
|
133
|
-
<div class="info-row">
|
|
134
|
-
<label class="info-label">Last updated:</label>
|
|
135
|
-
<span class="info-value">{{ formatDate(user.updated_at) }}</span>
|
|
136
|
-
</div>
|
|
137
|
-
</div>
|
|
138
|
-
</div>
|
|
139
|
-
|
|
140
|
-
<!-- Change Password Section -->
|
|
141
|
-
<div class="password-section">
|
|
142
|
-
<h2 class="section-title">
|
|
143
|
-
Change Password
|
|
144
|
-
</h2>
|
|
145
|
-
|
|
146
|
-
<form
|
|
147
|
-
class="password-form"
|
|
148
|
-
@submit.prevent="updatePassword"
|
|
149
|
-
>
|
|
150
|
-
<div class="form-group">
|
|
151
|
-
<label
|
|
152
|
-
for="currentPassword"
|
|
153
|
-
class="form-label"
|
|
154
|
-
>Current Password</label>
|
|
155
|
-
<input
|
|
156
|
-
id="currentPassword"
|
|
157
|
-
v-model="passwordForm.currentPassword"
|
|
158
|
-
type="password"
|
|
159
|
-
class="form-input"
|
|
160
|
-
required
|
|
161
|
-
:disabled="isPasswordLoading"
|
|
162
|
-
>
|
|
163
|
-
</div>
|
|
164
|
-
|
|
165
|
-
<div class="form-group">
|
|
166
|
-
<label
|
|
167
|
-
for="newPassword"
|
|
168
|
-
class="form-label"
|
|
169
|
-
>New Password</label>
|
|
170
|
-
<input
|
|
171
|
-
id="newPassword"
|
|
172
|
-
v-model="passwordForm.newPassword"
|
|
173
|
-
type="password"
|
|
174
|
-
class="form-input"
|
|
175
|
-
required
|
|
176
|
-
:minlength="moduleOptions.passwordValidation?.minLength || 8"
|
|
177
|
-
:class="{ error: passwordValidation.errors.value.length > 0 && passwordForm.newPassword }"
|
|
178
|
-
:disabled="isPasswordLoading"
|
|
179
|
-
>
|
|
180
|
-
|
|
181
|
-
<PasswordStrengthIndicator
|
|
182
|
-
:password="passwordForm.newPassword"
|
|
183
|
-
:validation-result="passwordValidation.validationResult.value"
|
|
184
|
-
/>
|
|
185
|
-
|
|
186
|
-
<!-- Password requirements -->
|
|
187
|
-
<small class="form-help">
|
|
188
|
-
Password must contain at least {{ moduleOptions.passwordValidation?.minLength || 8 }} characters
|
|
189
|
-
<span v-if="moduleOptions.passwordValidation?.requireUppercase">, including uppercase letters</span>
|
|
190
|
-
<span v-if="moduleOptions.passwordValidation?.requireLowercase">, lowercase letters</span>
|
|
191
|
-
<span v-if="moduleOptions.passwordValidation?.requireNumbers">, numbers</span>
|
|
192
|
-
<span v-if="moduleOptions.passwordValidation?.requireSpecialChars">, and special characters</span>.
|
|
193
|
-
</small>
|
|
194
|
-
</div>
|
|
195
|
-
|
|
196
|
-
<div class="form-group">
|
|
197
|
-
<label
|
|
198
|
-
for="newPasswordConfirmation"
|
|
199
|
-
class="form-label"
|
|
200
|
-
>Confirm New Password</label>
|
|
201
|
-
<input
|
|
202
|
-
id="newPasswordConfirmation"
|
|
203
|
-
v-model="passwordForm.newPasswordConfirmation"
|
|
204
|
-
type="password"
|
|
205
|
-
class="form-input"
|
|
206
|
-
required
|
|
207
|
-
:disabled="isPasswordLoading"
|
|
208
|
-
>
|
|
209
|
-
</div>
|
|
210
|
-
|
|
211
|
-
<div
|
|
212
|
-
v-if="passwordError"
|
|
213
|
-
class="error-message"
|
|
214
|
-
>
|
|
215
|
-
{{ passwordError }}
|
|
216
|
-
</div>
|
|
217
|
-
|
|
218
|
-
<div
|
|
219
|
-
v-if="passwordSuccess"
|
|
220
|
-
class="success-message"
|
|
221
|
-
>
|
|
222
|
-
{{ passwordSuccess }}
|
|
223
|
-
</div>
|
|
224
|
-
|
|
225
|
-
<button
|
|
226
|
-
type="submit"
|
|
227
|
-
class="btn btn-primary"
|
|
228
|
-
:disabled="isPasswordLoading"
|
|
229
|
-
>
|
|
230
|
-
<span v-if="isPasswordLoading">Updating...</span>
|
|
231
|
-
<span v-else>Update Password</span>
|
|
232
|
-
</button>
|
|
233
|
-
</form>
|
|
234
|
-
</div>
|
|
235
|
-
</div>
|
|
236
|
-
</template>
|
|
237
|
-
|
|
238
|
-
<style scoped>
|
|
239
|
-
.profile-form{margin:0 auto;max-width:600px;padding:20px}.password-section,.profile-section{background:#fff;border:1px solid #e2e8f0;border-radius:8px;margin-bottom:24px;padding:24px}.section-title{border-bottom:2px solid #e2e8f0;color:#1a202c;font-size:1.5rem;font-weight:600;margin:0 0 20px;padding-bottom:12px}.loading{color:#718096;font-style:italic;text-align:center}.profile-info{display:flex;flex-direction:column;gap:16px}.info-row{align-items:center;border-bottom:1px solid #f7fafc;display:flex;padding:12px 0}.info-row:last-child{border-bottom:none}.info-label{color:#4a5568;font-weight:600;margin-right:16px;min-width:120px}.info-value{color:#2d3748;flex:1}.password-form{gap:20px}.form-group,.password-form{display:flex;flex-direction:column}.form-group{gap:8px}.form-label{color:#4a5568;font-size:.875rem;font-weight:500}.form-input{border:1px solid #e2e8f0;border-radius:6px;font-size:1rem;padding:12px 16px;transition:border-color .2s,box-shadow .2s}.form-input:focus{border-color:#4299e1;box-shadow:0 0 0 3px rgba(66,153,225,.1);outline:none}.form-input:disabled{background-color:#f7fafc;cursor:not-allowed}.form-help{color:#718096;font-size:.75rem;margin-top:4px}.btn{align-self:flex-start;border:none;border-radius:6px;cursor:pointer;font-size:1rem;font-weight:500;padding:12px 24px;transition:background-color .2s,transform .1s}.btn:disabled{cursor:not-allowed;opacity:.6;transform:none}.btn-primary{background-color:#4299e1;color:#fff}.btn-primary:hover:not(:disabled){background-color:#3182ce;transform:translateY(-1px)}.error-message{background-color:#fed7d7;border:1px solid #feb2b2;border-radius:6px;color:#e53e3e;font-size:.875rem;padding:12px}.success-message{background-color:#f0fff4;border:1px solid #9ae6b4;border-radius:6px;color:#38a169;font-size:.875rem;padding:12px}
|
|
240
|
-
</style>
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { UserWithoutPassword } from '../../types.js';
|
|
2
|
-
interface ProfileFormProps {
|
|
3
|
-
apiEndpoint?: string;
|
|
4
|
-
updatePasswordEndpoint?: string;
|
|
5
|
-
}
|
|
6
|
-
declare const _default: import("vue").DefineComponent<ProfileFormProps, void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
7
|
-
error: (error: string) => any;
|
|
8
|
-
success: (user: UserWithoutPassword) => any;
|
|
9
|
-
"password-error": (error: string) => any;
|
|
10
|
-
"password-updated": () => any;
|
|
11
|
-
}, string, import("vue").PublicProps, Readonly<ProfileFormProps> & Readonly<{
|
|
12
|
-
onError?: ((error: string) => any) | undefined;
|
|
13
|
-
onSuccess?: ((user: UserWithoutPassword) => any) | undefined;
|
|
14
|
-
"onPassword-error"?: ((error: string) => any) | undefined;
|
|
15
|
-
"onPassword-updated"?: (() => any) | undefined;
|
|
16
|
-
}>, {
|
|
17
|
-
apiEndpoint: string;
|
|
18
|
-
updatePasswordEndpoint: string;
|
|
19
|
-
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
20
|
-
export default _default;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/runtime/server/api/{update-password.post.d.ts → auth/update-password.post.d.ts}
RENAMED
|
File without changes
|