@humanonlyweb/create-nuxtflare 0.2.1 → 0.2.2
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/dist/cli.js +17 -17
- package/dist/template/CLAUDE.md +1 -0
- package/dist/template/app/composables/use-account.ts +178 -0
- package/dist/template/app/composables/use-admin-login.ts +27 -0
- package/dist/template/app/composables/use-auth.ts +94 -295
- package/dist/template/app/composables/use-token-confirm.ts +52 -0
- package/dist/template/app/pages/account.vue +77 -39
- package/dist/template/app/pages/admin/login.vue +8 -23
- package/dist/template/app/pages/forgot-password.vue +9 -4
- package/dist/template/app/pages/login.vue +29 -10
- package/dist/template/app/pages/register.vue +18 -6
- package/dist/template/app/pages/reset/[token].vue +8 -5
- package/dist/template/nuxt.config.ts +6 -1
- package/dist/template/package.json +1 -0
- package/dist/template/shared/utils/schema-validation.ts +24 -3
- package/package.json +17 -17
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
definePageMeta({ middleware: 'auth' })
|
|
3
3
|
|
|
4
|
+
const profileFormRef = useTemplateRef<HTMLFormElement>('profile-form')
|
|
5
|
+
const passwordFormRef = useTemplateRef<HTMLFormElement>('password-form')
|
|
6
|
+
const emailFormRef = useTemplateRef<HTMLFormElement>('email-form')
|
|
7
|
+
const deleteFormRef = useTemplateRef<HTMLFormElement>('delete-form')
|
|
8
|
+
|
|
4
9
|
const {
|
|
5
10
|
me,
|
|
6
11
|
features,
|
|
7
12
|
canUseVerifiedActions,
|
|
8
13
|
sessionList,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
newPassword,
|
|
15
|
-
passwordCode,
|
|
16
|
-
deleteConfirm,
|
|
17
|
-
deletePassword,
|
|
18
|
-
deleteCode,
|
|
19
|
-
busy,
|
|
14
|
+
profile,
|
|
15
|
+
passwordForm,
|
|
16
|
+
emailForm,
|
|
17
|
+
deleteForm,
|
|
18
|
+
actionBusy,
|
|
20
19
|
notice,
|
|
21
20
|
errorMessage,
|
|
22
21
|
refreshSessions,
|
|
23
22
|
signOut,
|
|
24
23
|
signOutEverywhere,
|
|
25
24
|
resendVerification,
|
|
26
|
-
saveProfile,
|
|
27
|
-
savePassword,
|
|
28
|
-
requestEmailChange,
|
|
29
25
|
cancelEmailChange,
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
} = await useAccount({ profileFormRef, passwordFormRef, emailFormRef, deleteFormRef })
|
|
27
|
+
|
|
28
|
+
const { form: profileValues, errors: profileErrors, processing: profileProcessing, submit: saveProfile } = profile
|
|
29
|
+
const { form: passwordValues, errors: passwordErrors, processing: passwordProcessing, submit: savePassword } = passwordForm
|
|
30
|
+
const { form: emailValues, errors: emailErrors, processing: emailProcessing, submit: requestEmailChange } = emailForm
|
|
31
|
+
const { form: deleteValues, errors: deleteErrors, processing: deleteProcessing, submit: deleteAccount } = deleteForm
|
|
32
32
|
</script>
|
|
33
33
|
|
|
34
34
|
<template>
|
|
@@ -38,42 +38,60 @@ const {
|
|
|
38
38
|
<p v-if="notice" role="status">{{ notice }}</p>
|
|
39
39
|
|
|
40
40
|
<p>{{ me.username }} ({{ me.email }}) — email {{ me.emailStatus }}</p>
|
|
41
|
-
<button type="button" :disabled="
|
|
41
|
+
<button type="button" :disabled="actionBusy" @click="signOut">Sign out</button>
|
|
42
42
|
|
|
43
43
|
<section v-if="me.emailStatus === 'unverified'">
|
|
44
44
|
<h2>Confirm your email</h2>
|
|
45
45
|
<p>Check your inbox for a confirmation link, or request a fresh one.</p>
|
|
46
|
-
<button type="button" :disabled="
|
|
46
|
+
<button type="button" :disabled="actionBusy" @click="resendVerification">Resend verification email</button>
|
|
47
47
|
</section>
|
|
48
48
|
|
|
49
49
|
<template v-if="canUseVerifiedActions">
|
|
50
50
|
<section>
|
|
51
51
|
<h2>Profile</h2>
|
|
52
|
-
<form @submit
|
|
52
|
+
<form ref="profile-form" novalidate @submit="saveProfile">
|
|
53
53
|
<label>
|
|
54
54
|
Username
|
|
55
|
-
<input v-model="username" autocomplete="username" required />
|
|
55
|
+
<input v-model="profileValues.username" name="username" autocomplete="username" :aria-invalid="Boolean(profileErrors.username)" required />
|
|
56
|
+
<span v-if="profileErrors.username" role="alert">{{ profileErrors.username }}</span>
|
|
56
57
|
</label>
|
|
57
|
-
<button type="submit" :disabled="
|
|
58
|
+
<button type="submit" :disabled="profileProcessing">Save username</button>
|
|
58
59
|
</form>
|
|
59
60
|
</section>
|
|
60
61
|
|
|
61
62
|
<section>
|
|
62
63
|
<h2>{{ me.hasPassword ? 'Change password' : 'Set password' }}</h2>
|
|
63
|
-
<form @submit
|
|
64
|
+
<form ref="password-form" novalidate @submit="savePassword">
|
|
64
65
|
<label v-if="me.hasPassword">
|
|
65
66
|
Current password
|
|
66
|
-
<input
|
|
67
|
+
<input
|
|
68
|
+
v-model="passwordValues.currentPassword"
|
|
69
|
+
name="currentPassword"
|
|
70
|
+
type="password"
|
|
71
|
+
autocomplete="current-password"
|
|
72
|
+
:aria-invalid="Boolean(passwordErrors.currentPassword)"
|
|
73
|
+
required
|
|
74
|
+
/>
|
|
75
|
+
<span v-if="passwordErrors.currentPassword" role="alert">{{ passwordErrors.currentPassword }}</span>
|
|
67
76
|
</label>
|
|
68
77
|
<label>
|
|
69
78
|
New password
|
|
70
|
-
<input
|
|
79
|
+
<input
|
|
80
|
+
v-model="passwordValues.newPassword"
|
|
81
|
+
name="newPassword"
|
|
82
|
+
type="password"
|
|
83
|
+
autocomplete="new-password"
|
|
84
|
+
:aria-invalid="Boolean(passwordErrors.newPassword)"
|
|
85
|
+
required
|
|
86
|
+
/>
|
|
87
|
+
<span v-if="passwordErrors.newPassword" role="alert">{{ passwordErrors.newPassword }}</span>
|
|
71
88
|
</label>
|
|
72
89
|
<label v-if="me.hasPassword && features.totp && me.totpStatus === 'enabled'">
|
|
73
90
|
Authenticator or recovery code
|
|
74
|
-
<input v-model="
|
|
91
|
+
<input v-model="passwordValues.code" name="code" autocomplete="one-time-code" :aria-invalid="Boolean(passwordErrors.code)" required />
|
|
92
|
+
<span v-if="passwordErrors.code" role="alert">{{ passwordErrors.code }}</span>
|
|
75
93
|
</label>
|
|
76
|
-
<button type="submit" :disabled="
|
|
94
|
+
<button type="submit" :disabled="passwordProcessing">{{ me.hasPassword ? 'Change password' : 'Set password' }}</button>
|
|
77
95
|
</form>
|
|
78
96
|
</section>
|
|
79
97
|
|
|
@@ -81,22 +99,32 @@ const {
|
|
|
81
99
|
<h2>Email address</h2>
|
|
82
100
|
<div v-if="me.pendingEmailChange">
|
|
83
101
|
<p>Pending change to {{ me.pendingEmailChange.email }}.</p>
|
|
84
|
-
<button type="button" :disabled="
|
|
102
|
+
<button type="button" :disabled="actionBusy" @click="cancelEmailChange">Cancel pending change</button>
|
|
85
103
|
</div>
|
|
86
|
-
<form v-else @submit
|
|
104
|
+
<form v-else ref="email-form" novalidate @submit="requestEmailChange">
|
|
87
105
|
<label>
|
|
88
106
|
New email
|
|
89
|
-
<input v-model="
|
|
107
|
+
<input v-model="emailValues.email" name="email" type="email" autocomplete="email" :aria-invalid="Boolean(emailErrors.email)" required />
|
|
108
|
+
<span v-if="emailErrors.email" role="alert">{{ emailErrors.email }}</span>
|
|
90
109
|
</label>
|
|
91
110
|
<label>
|
|
92
111
|
Current password
|
|
93
|
-
<input
|
|
112
|
+
<input
|
|
113
|
+
v-model="emailValues.password"
|
|
114
|
+
name="password"
|
|
115
|
+
type="password"
|
|
116
|
+
autocomplete="current-password"
|
|
117
|
+
:aria-invalid="Boolean(emailErrors.password)"
|
|
118
|
+
required
|
|
119
|
+
/>
|
|
120
|
+
<span v-if="emailErrors.password" role="alert">{{ emailErrors.password }}</span>
|
|
94
121
|
</label>
|
|
95
122
|
<label v-if="features.totp && me.totpStatus === 'enabled'">
|
|
96
123
|
Authenticator or recovery code
|
|
97
|
-
<input v-model="
|
|
124
|
+
<input v-model="emailValues.code" name="code" autocomplete="one-time-code" :aria-invalid="Boolean(emailErrors.code)" required />
|
|
125
|
+
<span v-if="emailErrors.code" role="alert">{{ emailErrors.code }}</span>
|
|
98
126
|
</label>
|
|
99
|
-
<button type="submit" :disabled="
|
|
127
|
+
<button type="submit" :disabled="emailProcessing">Change email</button>
|
|
100
128
|
</form>
|
|
101
129
|
</section>
|
|
102
130
|
|
|
@@ -109,27 +137,37 @@ const {
|
|
|
109
137
|
{{ item.device }} — last seen {{ item.lastSeenAt }}<span v-if="item.current"> (current)</span>
|
|
110
138
|
</li>
|
|
111
139
|
</ul>
|
|
112
|
-
<button type="button" :disabled="
|
|
113
|
-
<button type="button" :disabled="
|
|
140
|
+
<button type="button" :disabled="actionBusy" @click="refreshSessions()">Refresh sessions</button>
|
|
141
|
+
<button type="button" :disabled="actionBusy" @click="signOutEverywhere">Sign out everywhere</button>
|
|
114
142
|
</section>
|
|
115
143
|
</template>
|
|
116
144
|
|
|
117
145
|
<section>
|
|
118
146
|
<h2>Delete account</h2>
|
|
119
|
-
<form @submit
|
|
147
|
+
<form ref="delete-form" novalidate @submit="deleteAccount">
|
|
120
148
|
<label>
|
|
121
149
|
Type {{ me.username }} to confirm
|
|
122
|
-
<input v-model="
|
|
150
|
+
<input v-model="deleteValues.confirm" name="confirm" :aria-invalid="Boolean(deleteErrors.confirm)" required />
|
|
151
|
+
<span v-if="deleteErrors.confirm" role="alert">{{ deleteErrors.confirm }}</span>
|
|
123
152
|
</label>
|
|
124
153
|
<label v-if="me.hasPassword">
|
|
125
154
|
Current password
|
|
126
|
-
<input
|
|
155
|
+
<input
|
|
156
|
+
v-model="deleteValues.password"
|
|
157
|
+
name="password"
|
|
158
|
+
type="password"
|
|
159
|
+
autocomplete="current-password"
|
|
160
|
+
:aria-invalid="Boolean(deleteErrors.password)"
|
|
161
|
+
required
|
|
162
|
+
/>
|
|
163
|
+
<span v-if="deleteErrors.password" role="alert">{{ deleteErrors.password }}</span>
|
|
127
164
|
</label>
|
|
128
165
|
<label v-if="features.totp && me.totpStatus === 'enabled'">
|
|
129
166
|
Authenticator or recovery code
|
|
130
|
-
<input v-model="
|
|
167
|
+
<input v-model="deleteValues.code" name="code" autocomplete="one-time-code" :aria-invalid="Boolean(deleteErrors.code)" required />
|
|
168
|
+
<span v-if="deleteErrors.code" role="alert">{{ deleteErrors.code }}</span>
|
|
131
169
|
</label>
|
|
132
|
-
<button type="submit" :disabled="
|
|
170
|
+
<button type="submit" :disabled="deleteProcessing">Delete account</button>
|
|
133
171
|
</form>
|
|
134
172
|
</section>
|
|
135
173
|
</main>
|
|
@@ -1,39 +1,24 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const email = ref('')
|
|
5
|
-
const password = ref('')
|
|
6
|
-
const busy = ref(false)
|
|
7
|
-
const errorMessage = ref('')
|
|
8
|
-
|
|
9
|
-
const submit = async () => {
|
|
10
|
-
errorMessage.value = ''
|
|
11
|
-
busy.value = true
|
|
12
|
-
try {
|
|
13
|
-
await $fetch('/api/admin/session', { method: 'POST', body: { email: email.value, password: password.value } })
|
|
14
|
-
await navigateTo('/admin')
|
|
15
|
-
} catch (error) {
|
|
16
|
-
errorMessage.value = problemOf(error).message
|
|
17
|
-
} finally {
|
|
18
|
-
busy.value = false
|
|
19
|
-
}
|
|
20
|
-
}
|
|
2
|
+
const formRef = useTemplateRef<HTMLFormElement>('admin-login-form')
|
|
3
|
+
const { form, errors, processing, submit, errorMessage } = useAdminLogin({ formRef })
|
|
21
4
|
</script>
|
|
22
5
|
|
|
23
6
|
<template>
|
|
24
7
|
<main>
|
|
25
8
|
<h1>Admin sign in</h1>
|
|
26
9
|
<p v-if="errorMessage" role="alert">{{ errorMessage }}</p>
|
|
27
|
-
<form @submit
|
|
10
|
+
<form ref="admin-login-form" novalidate @submit="submit">
|
|
28
11
|
<label>
|
|
29
12
|
Email
|
|
30
|
-
<input v-model="email" type="email" autocomplete="username" required />
|
|
13
|
+
<input v-model="form.email" name="email" type="email" autocomplete="username" :aria-invalid="Boolean(errors.email)" required />
|
|
14
|
+
<span v-if="errors.email" role="alert">{{ errors.email }}</span>
|
|
31
15
|
</label>
|
|
32
16
|
<label>
|
|
33
17
|
Password
|
|
34
|
-
<input v-model="password" type="password" autocomplete="current-password" required />
|
|
18
|
+
<input v-model="form.password" name="password" type="password" autocomplete="current-password" :aria-invalid="Boolean(errors.password)" required />
|
|
19
|
+
<span v-if="errors.password" role="alert">{{ errors.password }}</span>
|
|
35
20
|
</label>
|
|
36
|
-
<button type="submit" :disabled="
|
|
21
|
+
<button type="submit" :disabled="processing">Sign in</button>
|
|
37
22
|
</form>
|
|
38
23
|
</main>
|
|
39
24
|
</template>
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
definePageMeta({ middleware: 'guest' })
|
|
3
3
|
|
|
4
|
+
const formRef = useTemplateRef<HTMLFormElement>('forgot-form')
|
|
4
5
|
const turnstile = ref<{ reset: () => void } | null>(null)
|
|
5
|
-
const {
|
|
6
|
+
const { form, errors, processing, submit, step, turnstileToken, errorMessage } = useForgotPassword({
|
|
7
|
+
formRef,
|
|
8
|
+
onResetCaptcha: () => turnstile.value?.reset(),
|
|
9
|
+
})
|
|
6
10
|
</script>
|
|
7
11
|
|
|
8
12
|
<template>
|
|
@@ -15,13 +19,14 @@ const { step, email, turnstileToken, busy, errorMessage, submit } = useForgotPas
|
|
|
15
19
|
<p><NuxtLink to="/login">Back to sign in</NuxtLink></p>
|
|
16
20
|
</template>
|
|
17
21
|
|
|
18
|
-
<form v-else @submit
|
|
22
|
+
<form v-else ref="forgot-form" novalidate @submit="submit">
|
|
19
23
|
<label>
|
|
20
24
|
Email
|
|
21
|
-
<input v-model="email" type="email" autocomplete="email" required />
|
|
25
|
+
<input v-model="form.email" name="email" type="email" autocomplete="email" :aria-invalid="Boolean(errors.email)" required />
|
|
26
|
+
<span v-if="errors.email" role="alert">{{ errors.email }}</span>
|
|
22
27
|
</label>
|
|
23
28
|
<TurnstileWidget ref="turnstile" v-model="turnstileToken" />
|
|
24
|
-
<button type="submit" :disabled="
|
|
29
|
+
<button type="submit" :disabled="processing">Send reset link</button>
|
|
25
30
|
<p><NuxtLink to="/login">Back to sign in</NuxtLink></p>
|
|
26
31
|
</form>
|
|
27
32
|
</main>
|
|
@@ -2,9 +2,18 @@
|
|
|
2
2
|
definePageMeta({ middleware: 'guest' })
|
|
3
3
|
|
|
4
4
|
const features = useFeatures()
|
|
5
|
+
const credentialsFormRef = useTemplateRef<HTMLFormElement>('credentials-form')
|
|
6
|
+
const totpFormRef = useTemplateRef<HTMLFormElement>('totp-form')
|
|
5
7
|
const turnstile = ref<{ reset: () => void } | null>(null)
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
|
|
9
|
+
const { step, credentials, totp, turnstileToken, errorMessage, rememberOAuthNext, backToCredentials } = useAuthLogin({
|
|
10
|
+
credentialsFormRef,
|
|
11
|
+
totpFormRef,
|
|
12
|
+
onResetCaptcha: () => turnstile.value?.reset(),
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
const { form: credForm, errors: credErrors, processing: credProcessing, submit: submitCredentials } = credentials
|
|
16
|
+
const { form: totpForm, errors: totpErrors, processing: totpProcessing, submit: submitTotp } = totp
|
|
8
17
|
</script>
|
|
9
18
|
|
|
10
19
|
<template>
|
|
@@ -12,28 +21,38 @@ const { step, identity, password, code, turnstileToken, busy, errorMessage, reme
|
|
|
12
21
|
<h1>Sign in</h1>
|
|
13
22
|
<p v-if="errorMessage" role="alert">{{ errorMessage }}</p>
|
|
14
23
|
|
|
15
|
-
<form v-if="step.kind === 'credentials'" @submit
|
|
24
|
+
<form v-if="step.kind === 'credentials'" ref="credentials-form" novalidate @submit="submitCredentials">
|
|
16
25
|
<label>
|
|
17
26
|
Email or username
|
|
18
|
-
<input v-model="identity" autocomplete="username" required />
|
|
27
|
+
<input v-model="credForm.identity" name="identity" autocomplete="username" :aria-invalid="Boolean(credErrors.identity)" required />
|
|
28
|
+
<span v-if="credErrors.identity" role="alert">{{ credErrors.identity }}</span>
|
|
19
29
|
</label>
|
|
20
30
|
<label>
|
|
21
31
|
Password
|
|
22
|
-
<input
|
|
32
|
+
<input
|
|
33
|
+
v-model="credForm.password"
|
|
34
|
+
name="password"
|
|
35
|
+
type="password"
|
|
36
|
+
autocomplete="current-password"
|
|
37
|
+
:aria-invalid="Boolean(credErrors.password)"
|
|
38
|
+
required
|
|
39
|
+
/>
|
|
40
|
+
<span v-if="credErrors.password" role="alert">{{ credErrors.password }}</span>
|
|
23
41
|
</label>
|
|
24
42
|
<TurnstileWidget ref="turnstile" v-model="turnstileToken" />
|
|
25
|
-
<button type="submit" :disabled="
|
|
43
|
+
<button type="submit" :disabled="credProcessing">Sign in</button>
|
|
26
44
|
<p><NuxtLink to="/forgot-password">Forgot your password?</NuxtLink></p>
|
|
27
45
|
</form>
|
|
28
46
|
|
|
29
|
-
<form v-else @submit
|
|
47
|
+
<form v-else ref="totp-form" novalidate @submit="submitTotp">
|
|
30
48
|
<p>Enter the 6-digit code from your authenticator app or a recovery code.</p>
|
|
31
49
|
<label>
|
|
32
50
|
Verification code
|
|
33
|
-
<input v-model="code" autocomplete="one-time-code" required />
|
|
51
|
+
<input v-model="totpForm.code" name="code" autocomplete="one-time-code" :aria-invalid="Boolean(totpErrors.code)" required />
|
|
52
|
+
<span v-if="totpErrors.code" role="alert">{{ totpErrors.code }}</span>
|
|
34
53
|
</label>
|
|
35
|
-
<button type="submit" :disabled="
|
|
36
|
-
<button type="button" :disabled="
|
|
54
|
+
<button type="submit" :disabled="totpProcessing">Verify</button>
|
|
55
|
+
<button type="button" :disabled="totpProcessing" @click="backToCredentials">Back</button>
|
|
37
56
|
</form>
|
|
38
57
|
|
|
39
58
|
<p v-if="features.googleOAuth && step.kind === 'credentials'">
|
|
@@ -1,29 +1,41 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
definePageMeta({ middleware: 'guest' })
|
|
3
3
|
|
|
4
|
+
const formRef = useTemplateRef<HTMLFormElement>('register-form')
|
|
4
5
|
const turnstile = ref<{ reset: () => void } | null>(null)
|
|
5
|
-
const {
|
|
6
|
+
const { form, errors, processing, submit, turnstileToken, errorMessage } = useAuthRegister({
|
|
7
|
+
formRef,
|
|
8
|
+
onResetCaptcha: () => turnstile.value?.reset(),
|
|
9
|
+
})
|
|
6
10
|
</script>
|
|
7
11
|
|
|
8
12
|
<template>
|
|
9
13
|
<main>
|
|
10
14
|
<h1>Create account</h1>
|
|
11
15
|
<p v-if="errorMessage" role="alert">{{ errorMessage }}</p>
|
|
12
|
-
<form @submit
|
|
16
|
+
<form ref="register-form" novalidate @submit="submit">
|
|
13
17
|
<label>
|
|
14
18
|
Username
|
|
15
|
-
<input v-model="username" autocomplete="username" required />
|
|
19
|
+
<input v-model="form.username" name="username" autocomplete="username" :aria-invalid="Boolean(errors.username)" required />
|
|
20
|
+
<span v-if="errors.username" role="alert">{{ errors.username }}</span>
|
|
16
21
|
</label>
|
|
17
22
|
<label>
|
|
18
23
|
Email
|
|
19
|
-
<input v-model="email" type="email" autocomplete="email" required />
|
|
24
|
+
<input v-model="form.email" name="email" type="email" autocomplete="email" :aria-invalid="Boolean(errors.email)" required />
|
|
25
|
+
<span v-if="errors.email" role="alert">{{ errors.email }}</span>
|
|
20
26
|
</label>
|
|
21
27
|
<label>
|
|
22
28
|
Password
|
|
23
|
-
<input v-model="password" type="password" autocomplete="new-password" required />
|
|
29
|
+
<input v-model="form.password" name="password" type="password" autocomplete="new-password" :aria-invalid="Boolean(errors.password)" required />
|
|
30
|
+
<span v-if="errors.password" role="alert">{{ errors.password }}</span>
|
|
31
|
+
</label>
|
|
32
|
+
<label>
|
|
33
|
+
Confirm password
|
|
34
|
+
<input v-model="form.confirm" name="confirm" type="password" autocomplete="new-password" :aria-invalid="Boolean(errors.confirm)" required />
|
|
35
|
+
<span v-if="errors.confirm" role="alert">{{ errors.confirm }}</span>
|
|
24
36
|
</label>
|
|
25
37
|
<TurnstileWidget ref="turnstile" v-model="turnstileToken" />
|
|
26
|
-
<button type="submit" :disabled="
|
|
38
|
+
<button type="submit" :disabled="processing">Create account</button>
|
|
27
39
|
</form>
|
|
28
40
|
</main>
|
|
29
41
|
</template>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
const
|
|
2
|
+
const formRef = useTemplateRef<HTMLFormElement>('reset-form')
|
|
3
|
+
const { form, errors, processing, submit, step, errorMessage } = usePasswordReset({ formRef })
|
|
3
4
|
</script>
|
|
4
5
|
|
|
5
6
|
<template>
|
|
@@ -16,16 +17,18 @@ const { step, password, confirm, busy, errorMessage, submit } = usePasswordReset
|
|
|
16
17
|
<p>Your password has been updated and existing sessions were signed out.</p>
|
|
17
18
|
<p><NuxtLink to="/login">Sign in</NuxtLink></p>
|
|
18
19
|
</template>
|
|
19
|
-
<form v-else @submit
|
|
20
|
+
<form v-else ref="reset-form" novalidate @submit="submit">
|
|
20
21
|
<label>
|
|
21
22
|
New password
|
|
22
|
-
<input v-model="password" type="password" autocomplete="new-password" required />
|
|
23
|
+
<input v-model="form.password" name="password" type="password" autocomplete="new-password" :aria-invalid="Boolean(errors.password)" required />
|
|
24
|
+
<span v-if="errors.password" role="alert">{{ errors.password }}</span>
|
|
23
25
|
</label>
|
|
24
26
|
<label>
|
|
25
27
|
Confirm password
|
|
26
|
-
<input v-model="confirm" type="password" autocomplete="new-password" required />
|
|
28
|
+
<input v-model="form.confirm" name="confirm" type="password" autocomplete="new-password" :aria-invalid="Boolean(errors.confirm)" required />
|
|
29
|
+
<span v-if="errors.confirm" role="alert">{{ errors.confirm }}</span>
|
|
27
30
|
</label>
|
|
28
|
-
<button type="submit" :disabled="
|
|
31
|
+
<button type="submit" :disabled="processing">Update password</button>
|
|
29
32
|
</form>
|
|
30
33
|
</main>
|
|
31
34
|
</template>
|
|
@@ -15,8 +15,13 @@ const features = {
|
|
|
15
15
|
|
|
16
16
|
export default defineNuxtConfig({
|
|
17
17
|
devtools: { enabled: true },
|
|
18
|
-
modules: ['nuxt-auth-utils', '@humanonlyweb/cf-access/nuxt'],
|
|
18
|
+
modules: ['nuxt-auth-utils', '@humanonlyweb/cf-access/nuxt', '@humanonlyweb/ui/nuxt'],
|
|
19
19
|
|
|
20
|
+
ui: {
|
|
21
|
+
prefix: 'Ui',
|
|
22
|
+
css: true,
|
|
23
|
+
composables: true,
|
|
24
|
+
},
|
|
20
25
|
cfAccess: { protect: ['/admin/**', '/api/admin/**'] },
|
|
21
26
|
compatibilityDate: 'latest',
|
|
22
27
|
|
|
@@ -35,6 +35,10 @@ export const SecondFactorCodeField = Schema.Trim.check(
|
|
|
35
35
|
|
|
36
36
|
export const TotpSixDigitField = Schema.Trim.check(Schema.isPattern(/^\d{6}$/, { message: 'Enter the 6-digit code from your authenticator app.' }))
|
|
37
37
|
|
|
38
|
+
const passwordsMatch = Schema.makeFilter((value: { readonly password: string; readonly confirm: string }) =>
|
|
39
|
+
value.password === value.confirm ? undefined : { path: ['confirm'], issue: 'Passwords do not match.' },
|
|
40
|
+
)
|
|
41
|
+
|
|
38
42
|
export const LoginFormSchema = Schema.toStandardSchemaV1(
|
|
39
43
|
formStruct({
|
|
40
44
|
identity: required(254, 'Enter your email or username.'),
|
|
@@ -42,18 +46,35 @@ export const LoginFormSchema = Schema.toStandardSchemaV1(
|
|
|
42
46
|
}),
|
|
43
47
|
)
|
|
44
48
|
|
|
49
|
+
export const TotpCodeFormSchema = Schema.toStandardSchemaV1(formStruct({ code: SecondFactorCodeField }))
|
|
50
|
+
|
|
45
51
|
export const RegisterFormSchema = Schema.toStandardSchemaV1(
|
|
46
52
|
formStruct({
|
|
47
53
|
username: UsernameField,
|
|
48
54
|
email: EmailField,
|
|
49
55
|
password: PasswordField,
|
|
50
56
|
confirm: Schema.String,
|
|
51
|
-
}),
|
|
57
|
+
}).check(passwordsMatch),
|
|
52
58
|
)
|
|
53
59
|
|
|
54
60
|
export const ForgotPasswordFormSchema = Schema.toStandardSchemaV1(formStruct({ email: EmailField }))
|
|
55
|
-
|
|
56
|
-
export const
|
|
61
|
+
|
|
62
|
+
export const ResetPasswordFormSchema = Schema.toStandardSchemaV1(formStruct({ password: PasswordField, confirm: Schema.String }).check(passwordsMatch))
|
|
63
|
+
|
|
64
|
+
export const ChangeEmailFormSchema = Schema.toStandardSchemaV1(formStruct({ email: EmailField, password: NonEmptyPasswordField, code: Schema.String }))
|
|
65
|
+
|
|
57
66
|
export const ProfileFormSchema = Schema.toStandardSchemaV1(formStruct({ username: UsernameField }))
|
|
58
67
|
|
|
68
|
+
export const SetPasswordFormSchema = Schema.toStandardSchemaV1(formStruct({ currentPassword: Schema.String, newPassword: PasswordField, code: Schema.String }))
|
|
69
|
+
|
|
70
|
+
export const DeleteAccountFormSchema = Schema.toStandardSchemaV1(
|
|
71
|
+
formStruct({
|
|
72
|
+
confirm: required(64, 'Type your username to confirm.'),
|
|
73
|
+
password: Schema.String,
|
|
74
|
+
code: Schema.String,
|
|
75
|
+
}),
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
export const AdminLoginFormSchema = Schema.toStandardSchemaV1(formStruct({ email: EmailField, password: NonEmptyPasswordField }))
|
|
79
|
+
|
|
59
80
|
export const matchesConfirm = (typed: string, expected: string) => typed.trim().toLowerCase() === expected.toLowerCase()
|
package/package.json
CHANGED
|
@@ -1,29 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@humanonlyweb/create-nuxtflare",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Scaffold a Nuxt 5 + Cloudflare Workers + D1 + Effect v4 app with explicit auth, TOTP 2FA, and admin.",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"repository": {
|
|
7
|
-
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/humanonlyweb/nuxtflare.git"
|
|
9
|
-
},
|
|
10
|
-
"homepage": "https://github.com/humanonlyweb/nuxtflare#readme",
|
|
11
|
-
"bugs": {
|
|
12
|
-
"url": "https://github.com/humanonlyweb/nuxtflare/issues"
|
|
13
|
-
},
|
|
14
5
|
"keywords": [
|
|
15
|
-
"nuxt",
|
|
16
|
-
"nuxt5",
|
|
17
6
|
"cloudflare",
|
|
18
7
|
"cloudflare-workers",
|
|
8
|
+
"create",
|
|
19
9
|
"d1",
|
|
20
10
|
"effect",
|
|
21
|
-
"
|
|
22
|
-
"
|
|
11
|
+
"nuxt",
|
|
12
|
+
"nuxt5",
|
|
13
|
+
"starter"
|
|
23
14
|
],
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
15
|
+
"homepage": "https://github.com/humanonlyweb/nuxtflare#readme",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/humanonlyweb/nuxtflare/issues"
|
|
18
|
+
},
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/humanonlyweb/nuxtflare.git"
|
|
27
23
|
},
|
|
28
24
|
"bin": {
|
|
29
25
|
"create-nuxtflare": "./dist/cli.js",
|
|
@@ -32,6 +28,10 @@
|
|
|
32
28
|
"files": [
|
|
33
29
|
"dist"
|
|
34
30
|
],
|
|
31
|
+
"type": "module",
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "bun scripts/build.ts",
|
|
37
37
|
"test": "bun test src/scaffold.test.ts",
|