nuxt-users 1.3.0 → 1.5.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 +61 -0
- package/dist/cli.mjs +12 -30
- package/dist/module.d.mts +1 -1
- package/dist/module.d.ts +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +38 -1
- package/dist/runtime/components/LoginForm.vue +51 -4
- package/dist/runtime/components/LoginForm.vue.d.ts +13 -4
- package/dist/runtime/components/PasswordStrengthIndicator.vue +132 -0
- package/dist/runtime/components/PasswordStrengthIndicator.vue.d.ts +12 -0
- package/dist/runtime/components/ProfileForm.vue +240 -0
- package/dist/runtime/components/ProfileForm.vue.d.ts +20 -0
- package/dist/runtime/components/ResetPasswordForm.vue +30 -4
- package/dist/runtime/composables/useAuth.d.ts +20 -2
- package/dist/runtime/composables/useAuth.js +53 -2
- package/dist/runtime/composables/usePasswordValidation.d.ts +33 -0
- package/dist/runtime/composables/usePasswordValidation.js +37 -0
- package/dist/runtime/plugin.js +46 -1
- package/dist/runtime/server/api/auth/reset-password.post.js +9 -3
- package/dist/runtime/server/api/profile/update-password.post.d.ts +4 -0
- package/dist/runtime/server/api/profile/update-password.post.js +60 -0
- package/dist/runtime/server/api/profile.get.d.ts +11 -0
- package/dist/runtime/server/api/profile.get.js +23 -0
- package/dist/shared/{nuxt-users.DZkU2AbH.mjs → nuxt-users.37k1R3_g.mjs} +172 -1
- package/dist/shared/{nuxt-users.DGRKT2Tq.d.mts → nuxt-users.CMEtv_Mw.d.mts} +64 -6
- package/dist/shared/{nuxt-users.DGRKT2Tq.d.ts → nuxt-users.CMEtv_Mw.d.ts} +64 -6
- package/dist/utils.d.mts +28 -2
- package/dist/utils.d.ts +28 -2
- package/dist/utils.mjs +1 -1
- package/package.json +3 -2
- package/dist/runtime/middleware/auth.global.d.ts +0 -2
- package/dist/runtime/middleware/auth.global.js +0 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,67 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
## v1.5.0
|
|
5
|
+
|
|
6
|
+
[compare changes](https://github.com/rrd108/nuxt-users/compare/v1.4.0...v1.5.0)
|
|
7
|
+
|
|
8
|
+
### 🚀 Enhancements
|
|
9
|
+
|
|
10
|
+
- Implement forgot password closes #57 ([#57](https://github.com/rrd108/nuxt-users/issues/57))
|
|
11
|
+
- Add profile page closes #58 ([#58](https://github.com/rrd108/nuxt-users/issues/58))
|
|
12
|
+
|
|
13
|
+
### 🩹 Fixes
|
|
14
|
+
|
|
15
|
+
- Css color ([1d72336](https://github.com/rrd108/nuxt-users/commit/1d72336))
|
|
16
|
+
- Auth middleware ([113b165](https://github.com/rrd108/nuxt-users/commit/113b165))
|
|
17
|
+
- Enhances auth middleware and improves logging ([f519bbc](https://github.com/rrd108/nuxt-users/commit/f519bbc))
|
|
18
|
+
- Playground colors ([f87ade1](https://github.com/rrd108/nuxt-users/commit/f87ade1))
|
|
19
|
+
- Enhances user authentication and data handling ([d15c77f](https://github.com/rrd108/nuxt-users/commit/d15c77f))
|
|
20
|
+
|
|
21
|
+
### 💅 Refactors
|
|
22
|
+
|
|
23
|
+
- Have a dedicated playground login page ([487d754](https://github.com/rrd108/nuxt-users/commit/487d754))
|
|
24
|
+
- Module options and defaults ([00aa094](https://github.com/rrd108/nuxt-users/commit/00aa094))
|
|
25
|
+
|
|
26
|
+
### 🏡 Chore
|
|
27
|
+
|
|
28
|
+
- **release:** V1.4.0 ([e07ca9a](https://github.com/rrd108/nuxt-users/commit/e07ca9a))
|
|
29
|
+
|
|
30
|
+
### ✅ Tests
|
|
31
|
+
|
|
32
|
+
- Do not run unit tests for various dbs ([5b5e3aa](https://github.com/rrd108/nuxt-users/commit/5b5e3aa))
|
|
33
|
+
|
|
34
|
+
### ❤️ Contributors
|
|
35
|
+
|
|
36
|
+
- Rrd108 ([@rrd108](https://github.com/rrd108))
|
|
37
|
+
|
|
38
|
+
## v1.4.0
|
|
39
|
+
|
|
40
|
+
[compare changes](https://github.com/rrd108/nuxt-users/compare/v1.3.0...v1.4.0)
|
|
41
|
+
|
|
42
|
+
### 🚀 Enhancements
|
|
43
|
+
|
|
44
|
+
- Implement forgot password closes #57 ([#57](https://github.com/rrd108/nuxt-users/issues/57))
|
|
45
|
+
|
|
46
|
+
### 🩹 Fixes
|
|
47
|
+
|
|
48
|
+
- Css color ([1d72336](https://github.com/rrd108/nuxt-users/commit/1d72336))
|
|
49
|
+
- Auth middleware ([113b165](https://github.com/rrd108/nuxt-users/commit/113b165))
|
|
50
|
+
- Enhances auth middleware and improves logging ([f519bbc](https://github.com/rrd108/nuxt-users/commit/f519bbc))
|
|
51
|
+
- Playground colors ([f87ade1](https://github.com/rrd108/nuxt-users/commit/f87ade1))
|
|
52
|
+
|
|
53
|
+
### 💅 Refactors
|
|
54
|
+
|
|
55
|
+
- Have a dedicated playground login page ([487d754](https://github.com/rrd108/nuxt-users/commit/487d754))
|
|
56
|
+
|
|
57
|
+
### 🏡 Chore
|
|
58
|
+
|
|
59
|
+
- **release:** V1.3.0 ([b127043](https://github.com/rrd108/nuxt-users/commit/b127043))
|
|
60
|
+
|
|
61
|
+
### ❤️ Contributors
|
|
62
|
+
|
|
63
|
+
- Rrd108 ([@rrd108](https://github.com/rrd108))
|
|
64
|
+
|
|
4
65
|
## v1.3.0
|
|
5
66
|
|
|
6
67
|
[compare changes](https://github.com/rrd108/nuxt-users/compare/v1.2.0...v1.3.0)
|
package/dist/cli.mjs
CHANGED
|
@@ -2,36 +2,11 @@
|
|
|
2
2
|
import { defineCommand, runMain } from 'citty';
|
|
3
3
|
import 'db0';
|
|
4
4
|
import 'bcrypt';
|
|
5
|
-
import { r as runMigrations, a as createUser$1, d as createUsersTable$1, e as createPersonalAccessTokensTable$1, g as createPasswordResetTokensTable$1, h as createMigrationsTable$1 } from './shared/nuxt-users.
|
|
5
|
+
import { r as runMigrations, i as getPasswordValidationOptions, v as validatePassword, a as createUser$1, d as createUsersTable$1, e as createPersonalAccessTokensTable$1, g as createPasswordResetTokensTable$1, h as createMigrationsTable$1 } from './shared/nuxt-users.37k1R3_g.mjs';
|
|
6
|
+
import { defaultOptions } from './module.mjs';
|
|
6
7
|
import { loadNuxt } from '@nuxt/kit';
|
|
8
|
+
import 'defu';
|
|
7
9
|
|
|
8
|
-
const defaultOptions = {
|
|
9
|
-
connector: {
|
|
10
|
-
name: "sqlite",
|
|
11
|
-
options: {
|
|
12
|
-
path: "./data/users.sqlite3"
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
tables: {
|
|
16
|
-
migrations: "migrations",
|
|
17
|
-
users: "users",
|
|
18
|
-
personalAccessTokens: "personal_access_tokens",
|
|
19
|
-
passwordResetTokens: "password_reset_tokens"
|
|
20
|
-
},
|
|
21
|
-
mailer: {
|
|
22
|
-
host: "smtp.ethereal.email",
|
|
23
|
-
port: 587,
|
|
24
|
-
secure: false,
|
|
25
|
-
auth: {
|
|
26
|
-
user: "user@ethereal.email",
|
|
27
|
-
pass: "password"
|
|
28
|
-
},
|
|
29
|
-
defaults: {
|
|
30
|
-
from: '"Nuxt Users Module" <noreply@example.com>'
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
passwordResetBaseUrl: "http://localhost:3000"
|
|
34
|
-
};
|
|
35
10
|
const getOptionsFromEnv = () => {
|
|
36
11
|
const connectorName = process.env.DB_CONNECTOR || "sqlite";
|
|
37
12
|
let connectorOptions;
|
|
@@ -74,7 +49,7 @@ const loadOptions = async () => {
|
|
|
74
49
|
try {
|
|
75
50
|
console.log("[Nuxt Users] Loading Nuxt project...");
|
|
76
51
|
const nuxt = await loadNuxt({ cwd: process.cwd() });
|
|
77
|
-
const nuxtUsersConfig = nuxt.options.
|
|
52
|
+
const nuxtUsersConfig = nuxt.options.nuxtUsers;
|
|
78
53
|
await nuxt.close();
|
|
79
54
|
if (nuxtUsersConfig) {
|
|
80
55
|
console.log("[Nuxt Users] Using configuration from Nuxt project");
|
|
@@ -144,6 +119,13 @@ const createUser = defineCommand({
|
|
|
144
119
|
const { email, name, password, role } = args;
|
|
145
120
|
const options = await loadOptions();
|
|
146
121
|
try {
|
|
122
|
+
const passwordOptions = getPasswordValidationOptions(options);
|
|
123
|
+
const passwordValidation = validatePassword(password, passwordOptions);
|
|
124
|
+
if (!passwordValidation.isValid) {
|
|
125
|
+
console.error("[Nuxt Users] Password validation failed:");
|
|
126
|
+
passwordValidation.errors.forEach((error) => console.error(` - ${error}`));
|
|
127
|
+
process.exit(1);
|
|
128
|
+
}
|
|
147
129
|
const user = await createUser$1({ email, name, password, role }, options);
|
|
148
130
|
console.log(`[Nuxt Users] User created successfully: ${user.email} (role: ${user.role})`);
|
|
149
131
|
process.exit(0);
|
|
@@ -248,7 +230,7 @@ const projectInfo = defineCommand({
|
|
|
248
230
|
} else {
|
|
249
231
|
console.log("[Nuxt Users] \u26A0\uFE0F Nuxt Users module not configured in runtime config");
|
|
250
232
|
}
|
|
251
|
-
const publicConfig = nuxt.options.runtimeConfig?.
|
|
233
|
+
const publicConfig = nuxt.options.runtimeConfig?.nuxtUsers;
|
|
252
234
|
if (publicConfig) {
|
|
253
235
|
console.log("[Nuxt Users] \u{1F30D} Public runtime config:");
|
|
254
236
|
console.log("[Nuxt Users] Users table exists:", publicConfig.tables?.users);
|
package/dist/module.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
-
import { M as ModuleOptions } from './shared/nuxt-users.
|
|
2
|
+
import { M as ModuleOptions } from './shared/nuxt-users.CMEtv_Mw.mjs';
|
|
3
3
|
|
|
4
4
|
declare const defaultOptions: ModuleOptions;
|
|
5
5
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
package/dist/module.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
-
import { M as ModuleOptions } from './shared/nuxt-users.
|
|
2
|
+
import { M as ModuleOptions } from './shared/nuxt-users.CMEtv_Mw.js';
|
|
3
3
|
|
|
4
4
|
declare const defaultOptions: ModuleOptions;
|
|
5
5
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -29,8 +29,17 @@ const defaultOptions = {
|
|
|
29
29
|
from: '"Nuxt Users Module" <noreply@example.com>'
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
|
+
passwordResetBaseUrl: "http://localhost:3000",
|
|
32
33
|
auth: {
|
|
33
34
|
whitelist: ["/login"]
|
|
35
|
+
},
|
|
36
|
+
passwordValidation: {
|
|
37
|
+
minLength: 8,
|
|
38
|
+
requireUppercase: true,
|
|
39
|
+
requireLowercase: true,
|
|
40
|
+
requireNumbers: true,
|
|
41
|
+
requireSpecialChars: true,
|
|
42
|
+
preventCommonPasswords: true
|
|
34
43
|
}
|
|
35
44
|
};
|
|
36
45
|
const module = defineNuxtModule({
|
|
@@ -52,7 +61,21 @@ const module = defineNuxtModule({
|
|
|
52
61
|
passwordResetTokens: options.tables?.passwordResetTokens || defaultOptions.tables.passwordResetTokens
|
|
53
62
|
},
|
|
54
63
|
auth: {
|
|
55
|
-
whitelist:
|
|
64
|
+
whitelist: [...defaultOptions.auth?.whitelist || [], ...options.auth?.whitelist || []]
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
nuxt.options.runtimeConfig.public = nuxt.options.runtimeConfig.public || {};
|
|
68
|
+
nuxt.options.runtimeConfig.public.nuxtUsers = {
|
|
69
|
+
passwordValidation: {
|
|
70
|
+
minLength: options.passwordValidation?.minLength || defaultOptions.passwordValidation.minLength,
|
|
71
|
+
requireUppercase: options.passwordValidation?.requireUppercase ?? defaultOptions.passwordValidation.requireUppercase,
|
|
72
|
+
requireLowercase: options.passwordValidation?.requireLowercase ?? defaultOptions.passwordValidation.requireLowercase,
|
|
73
|
+
requireNumbers: options.passwordValidation?.requireNumbers ?? defaultOptions.passwordValidation.requireNumbers,
|
|
74
|
+
requireSpecialChars: options.passwordValidation?.requireSpecialChars ?? defaultOptions.passwordValidation.requireSpecialChars,
|
|
75
|
+
preventCommonPasswords: options.passwordValidation?.preventCommonPasswords ?? defaultOptions.passwordValidation.preventCommonPasswords
|
|
76
|
+
},
|
|
77
|
+
auth: {
|
|
78
|
+
whitelist: [...defaultOptions.auth?.whitelist || [], ...options.auth?.whitelist || []]
|
|
56
79
|
}
|
|
57
80
|
};
|
|
58
81
|
addPlugin({
|
|
@@ -80,6 +103,16 @@ const module = defineNuxtModule({
|
|
|
80
103
|
method: "get",
|
|
81
104
|
handler: resolver.resolve("./runtime/server/api/logout.get")
|
|
82
105
|
});
|
|
106
|
+
addServerHandler({
|
|
107
|
+
route: "/api/profile",
|
|
108
|
+
method: "get",
|
|
109
|
+
handler: resolver.resolve("./runtime/server/api/profile.get")
|
|
110
|
+
});
|
|
111
|
+
addServerHandler({
|
|
112
|
+
route: "/api/profile/update-password",
|
|
113
|
+
method: "post",
|
|
114
|
+
handler: resolver.resolve("./runtime/server/api/profile/update-password.post")
|
|
115
|
+
});
|
|
83
116
|
addComponent({
|
|
84
117
|
name: "LoginForm",
|
|
85
118
|
filePath: resolver.resolve("./runtime/components/LoginForm.vue")
|
|
@@ -96,6 +129,10 @@ const module = defineNuxtModule({
|
|
|
96
129
|
name: "LogoutLink",
|
|
97
130
|
filePath: resolver.resolve("./runtime/components/LogoutLink.vue")
|
|
98
131
|
});
|
|
132
|
+
addComponent({
|
|
133
|
+
name: "ProfileForm",
|
|
134
|
+
filePath: resolver.resolve("./runtime/components/ProfileForm.vue")
|
|
135
|
+
});
|
|
99
136
|
nuxt.options.css = nuxt.options.css || [];
|
|
100
137
|
nuxt.options.css.push(resolver.resolve("./runtime/assets/colors.css"));
|
|
101
138
|
}
|
|
@@ -3,11 +3,14 @@ import { ref } from "vue";
|
|
|
3
3
|
import { navigateTo } from "#app";
|
|
4
4
|
const props = defineProps({
|
|
5
5
|
apiEndpoint: { type: String, required: false, default: "/api/login" },
|
|
6
|
-
redirectTo: { type: String, required: false, default: "/" }
|
|
6
|
+
redirectTo: { type: String, required: false, default: "/" },
|
|
7
|
+
forgotPasswordEndpoint: { type: String, required: false, default: "/api/auth/forgot-password" }
|
|
7
8
|
});
|
|
8
|
-
const emit = defineEmits(["success", "error", "submit"]);
|
|
9
|
+
const emit = defineEmits(["success", "error", "forgot-password-error", "submit", "forgot-password-success"]);
|
|
9
10
|
const isLoading = ref(false);
|
|
11
|
+
const isForgotPasswordLoading = ref(false);
|
|
10
12
|
const error = ref("");
|
|
13
|
+
const forgotPasswordMessage = ref("");
|
|
11
14
|
const formData = ref({
|
|
12
15
|
email: "",
|
|
13
16
|
password: "",
|
|
@@ -37,6 +40,31 @@ const handleSubmit = async () => {
|
|
|
37
40
|
isLoading.value = false;
|
|
38
41
|
}
|
|
39
42
|
};
|
|
43
|
+
const handleForgotPassword = async () => {
|
|
44
|
+
if (!formData.value.email) {
|
|
45
|
+
error.value = "Please enter your email address first";
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
isForgotPasswordLoading.value = true;
|
|
49
|
+
forgotPasswordMessage.value = "";
|
|
50
|
+
error.value = "";
|
|
51
|
+
try {
|
|
52
|
+
const response = await $fetch(props.forgotPasswordEndpoint, {
|
|
53
|
+
method: "POST",
|
|
54
|
+
body: {
|
|
55
|
+
email: formData.value.email
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
forgotPasswordMessage.value = response.message;
|
|
59
|
+
emit("forgot-password-success");
|
|
60
|
+
} catch (err) {
|
|
61
|
+
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 send password reset email";
|
|
62
|
+
error.value = errorMessage;
|
|
63
|
+
emit("forgot-password-error", errorMessage);
|
|
64
|
+
} finally {
|
|
65
|
+
isForgotPasswordLoading.value = false;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
40
68
|
</script>
|
|
41
69
|
|
|
42
70
|
<template>
|
|
@@ -119,13 +147,32 @@ const handleSubmit = async () => {
|
|
|
119
147
|
<a
|
|
120
148
|
href="#"
|
|
121
149
|
class="forgot-link"
|
|
150
|
+
:class="{ loading: isForgotPasswordLoading }"
|
|
151
|
+
@click.prevent="handleForgotPassword"
|
|
122
152
|
>
|
|
123
|
-
|
|
153
|
+
<span
|
|
154
|
+
v-if="isForgotPasswordLoading"
|
|
155
|
+
class="loading-spinner"
|
|
156
|
+
/>
|
|
157
|
+
{{ isForgotPasswordLoading ? "Sending..." : "Forgot your password?" }}
|
|
124
158
|
</a>
|
|
125
159
|
</p>
|
|
126
160
|
</div>
|
|
127
161
|
</slot>
|
|
128
162
|
|
|
163
|
+
<!-- Success message slot -->
|
|
164
|
+
<slot
|
|
165
|
+
name="success-message"
|
|
166
|
+
:message="forgotPasswordMessage"
|
|
167
|
+
>
|
|
168
|
+
<div
|
|
169
|
+
v-if="forgotPasswordMessage"
|
|
170
|
+
class="success-message"
|
|
171
|
+
>
|
|
172
|
+
{{ forgotPasswordMessage }}
|
|
173
|
+
</div>
|
|
174
|
+
</slot>
|
|
175
|
+
|
|
129
176
|
<!-- Error message slot -->
|
|
130
177
|
<slot
|
|
131
178
|
name="error-message"
|
|
@@ -143,5 +190,5 @@ const handleSubmit = async () => {
|
|
|
143
190
|
</template>
|
|
144
191
|
|
|
145
192
|
<style scoped>
|
|
146
|
-
section{background:var(--color-bg-primary);border:1px solid var(--color-border);border-radius:.75em;box-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -1px rgba(0,0,0,.06);margin:0 auto;max-width:25rem;padding:1em}form{gap:1.5rem}.form-group,form{display:flex;flex-direction:column}label{display:block;font-weight:500;margin-bottom:.5em}input[type=email],input[type=password],label{color:var(--color-gray-700);font-size:.875rem}input[type=email],input[type=password]{background-color:var(--color-bg-secondary);border:1px solid var(--color-border-light);border-radius:8px;box-sizing:border-box;padding:.75em 1em;transition:all .2s ease-in-out;width:100%}input[type=email]:focus,input[type=password]:focus{background-color:var(--color-bg-primary);border-color:var(--color-primary);box-shadow:0 0 0 3px rgba(59,130,246,.1);outline:none}.login-header{margin-bottom:1em;text-align:center}.login-title{color:var(--color-gray-800);font-size:1.875rem;font-weight:700;line-height:1.2;margin:0 0 .5em}.login-subtitle{color:var(--color-gray-500);font-size:.875rem;line-height:1.5;margin:0}.remember-me{align-items:center;display:flex;gap:.5rem}input[type=checkbox]{margin:0;width:auto}.remember-me label{color:var(--color-gray-700);font-size:.875rem;margin:0}button[type=submit]{align-items:center;background-color:var(--color-primary);border:1px solid var(--color-primary);border-radius:8px;color:var(--color-white);cursor:pointer;display:flex;font-size:.875rem;font-weight:500;gap:.5rem;justify-content:center;min-height:44px;padding:.75em 1em;transition:all .2s ease-in-out;width:100%}button[type=submit]:hover:not(:disabled){background-color:var(--color-primary-dark);border-color:var(--color-primary-dark)}button[type=submit]:disabled{cursor:not-allowed;opacity:.6}.loading-spinner{animation:spin 1s linear infinite;border:2px solid var(--color-white);border-radius:50%;border-top:2px solid transparent;height:16px;width:16px}@keyframes spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}.login-footer{margin-top:1em;text-align:center}.forgot-password{margin:0}.forgot-link{color:var(--color-primary);font-size:.875rem;text-decoration:none;transition:color .2s ease-in-out}.forgot-link:hover{color:var(--color-primary-dark);text-decoration:underline}.error-message{background-color:var(--color-error-light);border:1px solid var(--color-error-border);border-radius:8px;color:var(--color-error)
|
|
193
|
+
section{background:linear-gradient(135deg,var(--color-bg-primary) 0,var(--color-bg-secondary) 100%);border:1px solid var(--color-border);border-radius:.75em;box-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -1px rgba(0,0,0,.06);margin:0 auto;max-width:25rem;padding:1em}form{gap:1.5rem}.form-group,form{display:flex;flex-direction:column}label{display:block;font-weight:500;margin-bottom:.5em}input[type=email],input[type=password],label{color:var(--color-gray-700);font-size:.875rem}input[type=email],input[type=password]{background-color:var(--color-bg-secondary);border:1px solid var(--color-border-light);border-radius:8px;box-sizing:border-box;padding:.75em 1em;transition:all .2s ease-in-out;width:100%}input[type=email]:focus,input[type=password]:focus{background-color:var(--color-bg-primary);border-color:var(--color-primary);box-shadow:0 0 0 3px rgba(59,130,246,.1);outline:none}.login-header{margin-bottom:1em;text-align:center}.login-title{color:var(--color-gray-800);font-size:1.875rem;font-weight:700;line-height:1.2;margin:0 0 .5em}.login-subtitle{color:var(--color-gray-500);font-size:.875rem;line-height:1.5;margin:0}.remember-me{align-items:center;display:flex;gap:.5rem}input[type=checkbox]{margin:0;width:auto}.remember-me label{color:var(--color-gray-700);font-size:.875rem;margin:0}button[type=submit]{align-items:center;background-color:var(--color-primary);border:1px solid var(--color-primary);border-radius:8px;color:var(--color-white);cursor:pointer;display:flex;font-size:.875rem;font-weight:500;gap:.5rem;justify-content:center;min-height:44px;padding:.75em 1em;transition:all .2s ease-in-out;width:100%}button[type=submit]:hover:not(:disabled){background-color:var(--color-primary-dark);border-color:var(--color-primary-dark)}button[type=submit]:disabled{cursor:not-allowed;opacity:.6}.loading-spinner{animation:spin 1s linear infinite;border:2px solid var(--color-white);border-radius:50%;border-top:2px solid transparent;height:16px;width:16px}@keyframes spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}.login-footer{margin-top:1em;text-align:center}.forgot-password{margin:0}.forgot-link{align-items:center;color:var(--color-primary);display:inline-flex;font-size:.875rem;gap:.5rem;text-decoration:none;transition:color .2s ease-in-out}.forgot-link:hover:not(.loading){color:var(--color-primary-dark);text-decoration:underline}.forgot-link.loading{cursor:not-allowed;opacity:.6;pointer-events:none}.error-message{background-color:var(--color-error-light);border:1px solid var(--color-error-border);border-radius:8px;color:var(--color-error)}.error-message,.success-message{font-size:.875rem;margin-top:1em;padding:.75em 1em;text-align:center}.success-message{background-color:var(--color-success-light);border:1px solid var(--color-success-border);border-radius:8px;color:var(--color-success)}@media (max-width:480px){.login-form-container{margin:1em;padding:1.5em}.login-title{font-size:1.5rem}}
|
|
147
194
|
</style>
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import type { LoginFormData, LoginFormProps,
|
|
1
|
+
import type { LoginFormData, LoginFormProps, UserWithoutPassword } from '../../types.js';
|
|
2
2
|
declare var __VLS_1: {}, __VLS_3: {}, __VLS_5: {}, __VLS_7: {}, __VLS_9: {}, __VLS_11: {}, __VLS_13: {
|
|
3
|
+
message: string;
|
|
4
|
+
}, __VLS_15: {
|
|
3
5
|
error: string;
|
|
4
6
|
};
|
|
5
7
|
type __VLS_Slots = {} & {
|
|
@@ -15,19 +17,26 @@ type __VLS_Slots = {} & {
|
|
|
15
17
|
} & {
|
|
16
18
|
footer?: (props: typeof __VLS_11) => any;
|
|
17
19
|
} & {
|
|
18
|
-
'
|
|
20
|
+
'success-message'?: (props: typeof __VLS_13) => any;
|
|
21
|
+
} & {
|
|
22
|
+
'error-message'?: (props: typeof __VLS_15) => any;
|
|
19
23
|
};
|
|
20
24
|
declare const __VLS_component: import("vue").DefineComponent<LoginFormProps, void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
21
25
|
error: (error: string) => any;
|
|
22
26
|
submit: (data: LoginFormData) => any;
|
|
23
|
-
success: (user:
|
|
27
|
+
success: (user: UserWithoutPassword) => any;
|
|
28
|
+
"forgot-password-error": (error: string) => any;
|
|
29
|
+
"forgot-password-success": () => any;
|
|
24
30
|
}, string, import("vue").PublicProps, Readonly<LoginFormProps> & Readonly<{
|
|
25
31
|
onError?: ((error: string) => any) | undefined;
|
|
26
32
|
onSubmit?: ((data: LoginFormData) => any) | undefined;
|
|
27
|
-
onSuccess?: ((user:
|
|
33
|
+
onSuccess?: ((user: UserWithoutPassword) => any) | undefined;
|
|
34
|
+
"onForgot-password-error"?: ((error: string) => any) | undefined;
|
|
35
|
+
"onForgot-password-success"?: (() => any) | undefined;
|
|
28
36
|
}>, {
|
|
29
37
|
apiEndpoint: string;
|
|
30
38
|
redirectTo: string;
|
|
39
|
+
forgotPasswordEndpoint: string;
|
|
31
40
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
32
41
|
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
33
42
|
export default _default;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
const props = defineProps({
|
|
4
|
+
password: { type: String, required: true },
|
|
5
|
+
validationResult: { type: [Object, null], required: true },
|
|
6
|
+
showHints: { type: Boolean, required: false, default: true },
|
|
7
|
+
showRules: { type: Boolean, required: false, default: true }
|
|
8
|
+
});
|
|
9
|
+
const hasErrors = computed(() => (props.validationResult?.errors?.length || 0) > 0);
|
|
10
|
+
const hasHints = computed(() => (props.validationResult?.hints?.length || 0) > 0);
|
|
11
|
+
const hasPassword = computed(() => props.password.length > 0);
|
|
12
|
+
const validationRules = computed(() => {
|
|
13
|
+
if (!props.password) return [];
|
|
14
|
+
const rules = [];
|
|
15
|
+
const minLength = 8;
|
|
16
|
+
const hasMinLength = props.password.length >= minLength;
|
|
17
|
+
rules.push({
|
|
18
|
+
text: `At least ${minLength} characters`,
|
|
19
|
+
passed: hasMinLength
|
|
20
|
+
});
|
|
21
|
+
const hasUppercase = /[A-Z]/.test(props.password);
|
|
22
|
+
rules.push({
|
|
23
|
+
text: "Contains uppercase letter (A-Z)",
|
|
24
|
+
passed: hasUppercase
|
|
25
|
+
});
|
|
26
|
+
const hasLowercase = /[a-z]/.test(props.password);
|
|
27
|
+
rules.push({
|
|
28
|
+
text: "Contains lowercase letter (a-z)",
|
|
29
|
+
passed: hasLowercase
|
|
30
|
+
});
|
|
31
|
+
const hasNumbers = /\d/.test(props.password);
|
|
32
|
+
rules.push({
|
|
33
|
+
text: "Contains number (0-9)",
|
|
34
|
+
passed: hasNumbers
|
|
35
|
+
});
|
|
36
|
+
const hasSpecialChars = /[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?]/.test(props.password);
|
|
37
|
+
rules.push({
|
|
38
|
+
text: "Contains special character (!@#$%^&*)",
|
|
39
|
+
passed: hasSpecialChars
|
|
40
|
+
});
|
|
41
|
+
return rules;
|
|
42
|
+
});
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
<template>
|
|
46
|
+
<!-- Password strength indicator -->
|
|
47
|
+
<div
|
|
48
|
+
v-if="hasPassword"
|
|
49
|
+
class="password-strength"
|
|
50
|
+
>
|
|
51
|
+
<div class="strength-bar">
|
|
52
|
+
<div
|
|
53
|
+
class="strength-fill"
|
|
54
|
+
:style="{
|
|
55
|
+
width: `${validationResult?.score || 0}%`,
|
|
56
|
+
backgroundColor: validationResult?.strength === 'weak' ? '#dc3545' : validationResult?.strength === 'medium' ? '#ffc107' : validationResult?.strength === 'strong' ? '#28a745' : '#6c757d'
|
|
57
|
+
}"
|
|
58
|
+
/>
|
|
59
|
+
</div>
|
|
60
|
+
<span
|
|
61
|
+
class="strength-text"
|
|
62
|
+
:style="{
|
|
63
|
+
color: validationResult?.strength === 'weak' ? '#dc3545' : validationResult?.strength === 'medium' ? '#ffc107' : validationResult?.strength === 'strong' ? '#28a745' : '#6c757d'
|
|
64
|
+
}"
|
|
65
|
+
>
|
|
66
|
+
{{ validationResult?.strength === "weak" ? "Weak" : validationResult?.strength === "medium" ? "Medium" : validationResult?.strength === "strong" ? "Strong" : "Unknown" }}
|
|
67
|
+
({{ validationResult?.score || 0 }}%)
|
|
68
|
+
</span>
|
|
69
|
+
</div>
|
|
70
|
+
|
|
71
|
+
<!-- Validation rules -->
|
|
72
|
+
<div
|
|
73
|
+
v-if="showRules && hasPassword"
|
|
74
|
+
class="validation-rules"
|
|
75
|
+
>
|
|
76
|
+
<div class="rules-title">
|
|
77
|
+
Password Requirements:
|
|
78
|
+
</div>
|
|
79
|
+
<ul class="rules-list">
|
|
80
|
+
<li
|
|
81
|
+
v-for="rule in validationRules"
|
|
82
|
+
:key="rule.text"
|
|
83
|
+
class="rule-item"
|
|
84
|
+
:class="{ 'rule-passed': rule.passed, 'rule-failed': !rule.passed }"
|
|
85
|
+
>
|
|
86
|
+
<span class="rule-icon">
|
|
87
|
+
{{ rule.passed ? "\u2713" : "\u2717" }}
|
|
88
|
+
</span>
|
|
89
|
+
<span class="rule-text">
|
|
90
|
+
{{ rule.text }}
|
|
91
|
+
</span>
|
|
92
|
+
</li>
|
|
93
|
+
</ul>
|
|
94
|
+
</div>
|
|
95
|
+
|
|
96
|
+
<!-- Validation errors -->
|
|
97
|
+
<div
|
|
98
|
+
v-if="hasErrors"
|
|
99
|
+
class="validation-errors"
|
|
100
|
+
>
|
|
101
|
+
<small
|
|
102
|
+
v-for="error in validationResult?.errors || []"
|
|
103
|
+
:key="String(error)"
|
|
104
|
+
class="error-text"
|
|
105
|
+
>
|
|
106
|
+
{{ error }}
|
|
107
|
+
</small>
|
|
108
|
+
</div>
|
|
109
|
+
|
|
110
|
+
<!-- Password improvement hints -->
|
|
111
|
+
<div
|
|
112
|
+
v-if="showHints && hasPassword && hasHints"
|
|
113
|
+
class="password-hints"
|
|
114
|
+
>
|
|
115
|
+
<div class="hint-title">
|
|
116
|
+
How to make your password stronger:
|
|
117
|
+
</div>
|
|
118
|
+
<ul class="hint-list">
|
|
119
|
+
<li
|
|
120
|
+
v-for="hint in validationResult?.hints || []"
|
|
121
|
+
:key="'hint-' + hint"
|
|
122
|
+
class="hint-item"
|
|
123
|
+
>
|
|
124
|
+
{{ hint }}
|
|
125
|
+
</li>
|
|
126
|
+
</ul>
|
|
127
|
+
</div>
|
|
128
|
+
</template>
|
|
129
|
+
|
|
130
|
+
<style scoped>
|
|
131
|
+
.password-strength{margin-top:8px}.strength-bar{background-color:#e9ecef;border-radius:2px;height:4px;margin-bottom:4px;overflow:hidden;width:100%}.strength-fill{height:100%;transition:width .3s ease,background-color .3s ease}.strength-text{font-size:.75rem;font-weight:500}.validation-rules{background-color:#f8f9fa;border:1px solid #e9ecef;border-radius:4px;margin-top:12px;padding:12px}.rules-title{color:#495057;font-size:.875rem;font-weight:600;margin-bottom:8px}.rules-list{list-style:none;margin:0;padding-left:0}.rule-item{align-items:center;display:flex;font-size:.875rem;margin-bottom:6px;transition:color .2s ease}.rule-item:last-child{margin-bottom:0}.rule-passed{color:#28a745}.rule-failed{color:#dc3545}.rule-icon{font-weight:700;margin-right:8px;min-width:16px;text-align:center}.rule-text{flex:1}.validation-errors{margin-top:8px}.error-text{color:#dc3545;display:block;font-size:.875rem;margin-bottom:4px}.error-text:last-child{margin-bottom:0}.password-hints{background-color:#f8f9fa;border:1px solid #e9ecef;border-radius:4px;margin-top:8px;padding:12px}.hint-title{color:#495057;font-size:.875rem;font-weight:600;margin-bottom:8px}.hint-list{margin:0;padding-left:16px}.hint-item{color:#6c757d;font-size:.875rem;margin-bottom:4px}.hint-item:last-child{margin-bottom:0}
|
|
132
|
+
</style>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PasswordValidationResult } from '../../utils/password-validation.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
password: string;
|
|
4
|
+
validationResult: PasswordValidationResult | null;
|
|
5
|
+
showHints?: boolean;
|
|
6
|
+
showRules?: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare const _default: import("vue").DefineComponent<Props, void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {
|
|
9
|
+
showHints: boolean;
|
|
10
|
+
showRules: boolean;
|
|
11
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
12
|
+
export default _default;
|