@humanonlyweb/create-nuxtflare 0.2.1 → 0.2.3

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.
@@ -1,34 +1,37 @@
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 {
10
+ ready,
5
11
  me,
6
12
  features,
7
13
  canUseVerifiedActions,
8
14
  sessionList,
9
- username,
10
- nextEmail,
11
- emailPassword,
12
- emailCode,
13
- currentPassword,
14
- newPassword,
15
- passwordCode,
16
- deleteConfirm,
17
- deletePassword,
18
- deleteCode,
19
- busy,
15
+ profile,
16
+ passwordForm,
17
+ emailForm,
18
+ deleteForm,
19
+ actionBusy,
20
20
  notice,
21
21
  errorMessage,
22
22
  refreshSessions,
23
23
  signOut,
24
24
  signOutEverywhere,
25
25
  resendVerification,
26
- saveProfile,
27
- savePassword,
28
- requestEmailChange,
29
26
  cancelEmailChange,
30
- deleteAccount,
31
- } = await useAccount()
27
+ } = useAccount({ profileFormRef, passwordFormRef, emailFormRef, deleteFormRef })
28
+
29
+ const { form: profileValues, errors: profileErrors, processing: profileProcessing, submit: saveProfile } = profile
30
+ const { form: passwordValues, errors: passwordErrors, processing: passwordProcessing, submit: savePassword } = passwordForm
31
+ const { form: emailValues, errors: emailErrors, processing: emailProcessing, submit: requestEmailChange } = emailForm
32
+ const { form: deleteValues, errors: deleteErrors, processing: deleteProcessing, submit: deleteAccount } = deleteForm
33
+
34
+ await ready
32
35
  </script>
33
36
 
34
37
  <template>
@@ -38,42 +41,60 @@ const {
38
41
  <p v-if="notice" role="status">{{ notice }}</p>
39
42
 
40
43
  <p>{{ me.username }} ({{ me.email }}) — email {{ me.emailStatus }}</p>
41
- <button type="button" :disabled="busy" @click="signOut">Sign out</button>
44
+ <button type="button" :disabled="actionBusy" @click="signOut">Sign out</button>
42
45
 
43
46
  <section v-if="me.emailStatus === 'unverified'">
44
47
  <h2>Confirm your email</h2>
45
48
  <p>Check your inbox for a confirmation link, or request a fresh one.</p>
46
- <button type="button" :disabled="busy" @click="resendVerification">Resend verification email</button>
49
+ <button type="button" :disabled="actionBusy" @click="resendVerification">Resend verification email</button>
47
50
  </section>
48
51
 
49
52
  <template v-if="canUseVerifiedActions">
50
53
  <section>
51
54
  <h2>Profile</h2>
52
- <form @submit.prevent="saveProfile">
55
+ <form ref="profile-form" novalidate @submit="saveProfile">
53
56
  <label>
54
57
  Username
55
- <input v-model="username" autocomplete="username" required />
58
+ <input v-model="profileValues.username" name="username" autocomplete="username" :aria-invalid="Boolean(profileErrors.username)" required />
59
+ <span v-if="profileErrors.username" role="alert">{{ profileErrors.username }}</span>
56
60
  </label>
57
- <button type="submit" :disabled="busy">Save username</button>
61
+ <button type="submit" :disabled="profileProcessing">Save username</button>
58
62
  </form>
59
63
  </section>
60
64
 
61
65
  <section>
62
66
  <h2>{{ me.hasPassword ? 'Change password' : 'Set password' }}</h2>
63
- <form @submit.prevent="savePassword">
67
+ <form ref="password-form" novalidate @submit="savePassword">
64
68
  <label v-if="me.hasPassword">
65
69
  Current password
66
- <input v-model="currentPassword" type="password" autocomplete="current-password" required />
70
+ <input
71
+ v-model="passwordValues.currentPassword"
72
+ name="currentPassword"
73
+ type="password"
74
+ autocomplete="current-password"
75
+ :aria-invalid="Boolean(passwordErrors.currentPassword)"
76
+ required
77
+ />
78
+ <span v-if="passwordErrors.currentPassword" role="alert">{{ passwordErrors.currentPassword }}</span>
67
79
  </label>
68
80
  <label>
69
81
  New password
70
- <input v-model="newPassword" type="password" autocomplete="new-password" required />
82
+ <input
83
+ v-model="passwordValues.newPassword"
84
+ name="newPassword"
85
+ type="password"
86
+ autocomplete="new-password"
87
+ :aria-invalid="Boolean(passwordErrors.newPassword)"
88
+ required
89
+ />
90
+ <span v-if="passwordErrors.newPassword" role="alert">{{ passwordErrors.newPassword }}</span>
71
91
  </label>
72
92
  <label v-if="me.hasPassword && features.totp && me.totpStatus === 'enabled'">
73
93
  Authenticator or recovery code
74
- <input v-model="passwordCode" autocomplete="one-time-code" required />
94
+ <input v-model="passwordValues.code" name="code" autocomplete="one-time-code" :aria-invalid="Boolean(passwordErrors.code)" required />
95
+ <span v-if="passwordErrors.code" role="alert">{{ passwordErrors.code }}</span>
75
96
  </label>
76
- <button type="submit" :disabled="busy">{{ me.hasPassword ? 'Change password' : 'Set password' }}</button>
97
+ <button type="submit" :disabled="passwordProcessing">{{ me.hasPassword ? 'Change password' : 'Set password' }}</button>
77
98
  </form>
78
99
  </section>
79
100
 
@@ -81,22 +102,32 @@ const {
81
102
  <h2>Email address</h2>
82
103
  <div v-if="me.pendingEmailChange">
83
104
  <p>Pending change to {{ me.pendingEmailChange.email }}.</p>
84
- <button type="button" :disabled="busy" @click="cancelEmailChange">Cancel pending change</button>
105
+ <button type="button" :disabled="actionBusy" @click="cancelEmailChange">Cancel pending change</button>
85
106
  </div>
86
- <form v-else @submit.prevent="requestEmailChange">
107
+ <form v-else ref="email-form" novalidate @submit="requestEmailChange">
87
108
  <label>
88
109
  New email
89
- <input v-model="nextEmail" type="email" autocomplete="email" required />
110
+ <input v-model="emailValues.email" name="email" type="email" autocomplete="email" :aria-invalid="Boolean(emailErrors.email)" required />
111
+ <span v-if="emailErrors.email" role="alert">{{ emailErrors.email }}</span>
90
112
  </label>
91
113
  <label>
92
114
  Current password
93
- <input v-model="emailPassword" type="password" autocomplete="current-password" required />
115
+ <input
116
+ v-model="emailValues.password"
117
+ name="password"
118
+ type="password"
119
+ autocomplete="current-password"
120
+ :aria-invalid="Boolean(emailErrors.password)"
121
+ required
122
+ />
123
+ <span v-if="emailErrors.password" role="alert">{{ emailErrors.password }}</span>
94
124
  </label>
95
125
  <label v-if="features.totp && me.totpStatus === 'enabled'">
96
126
  Authenticator or recovery code
97
- <input v-model="emailCode" autocomplete="one-time-code" required />
127
+ <input v-model="emailValues.code" name="code" autocomplete="one-time-code" :aria-invalid="Boolean(emailErrors.code)" required />
128
+ <span v-if="emailErrors.code" role="alert">{{ emailErrors.code }}</span>
98
129
  </label>
99
- <button type="submit" :disabled="busy">Change email</button>
130
+ <button type="submit" :disabled="emailProcessing">Change email</button>
100
131
  </form>
101
132
  </section>
102
133
 
@@ -109,27 +140,37 @@ const {
109
140
  {{ item.device }} — last seen {{ item.lastSeenAt }}<span v-if="item.current"> (current)</span>
110
141
  </li>
111
142
  </ul>
112
- <button type="button" :disabled="busy" @click="refreshSessions()">Refresh sessions</button>
113
- <button type="button" :disabled="busy" @click="signOutEverywhere">Sign out everywhere</button>
143
+ <button type="button" :disabled="actionBusy" @click="refreshSessions()">Refresh sessions</button>
144
+ <button type="button" :disabled="actionBusy" @click="signOutEverywhere">Sign out everywhere</button>
114
145
  </section>
115
146
  </template>
116
147
 
117
148
  <section>
118
149
  <h2>Delete account</h2>
119
- <form @submit.prevent="deleteAccount">
150
+ <form ref="delete-form" novalidate @submit="deleteAccount">
120
151
  <label>
121
152
  Type {{ me.username }} to confirm
122
- <input v-model="deleteConfirm" required />
153
+ <input v-model="deleteValues.confirm" name="confirm" :aria-invalid="Boolean(deleteErrors.confirm)" required />
154
+ <span v-if="deleteErrors.confirm" role="alert">{{ deleteErrors.confirm }}</span>
123
155
  </label>
124
156
  <label v-if="me.hasPassword">
125
157
  Current password
126
- <input v-model="deletePassword" type="password" autocomplete="current-password" required />
158
+ <input
159
+ v-model="deleteValues.password"
160
+ name="password"
161
+ type="password"
162
+ autocomplete="current-password"
163
+ :aria-invalid="Boolean(deleteErrors.password)"
164
+ required
165
+ />
166
+ <span v-if="deleteErrors.password" role="alert">{{ deleteErrors.password }}</span>
127
167
  </label>
128
168
  <label v-if="features.totp && me.totpStatus === 'enabled'">
129
169
  Authenticator or recovery code
130
- <input v-model="deleteCode" autocomplete="one-time-code" required />
170
+ <input v-model="deleteValues.code" name="code" autocomplete="one-time-code" :aria-invalid="Boolean(deleteErrors.code)" required />
171
+ <span v-if="deleteErrors.code" role="alert">{{ deleteErrors.code }}</span>
131
172
  </label>
132
- <button type="submit" :disabled="busy">Delete account</button>
173
+ <button type="submit" :disabled="deleteProcessing">Delete account</button>
133
174
  </form>
134
175
  </section>
135
176
  </main>
@@ -1,39 +1,24 @@
1
1
  <script setup lang="ts">
2
- import { problemOf } from '~/utils/api-error'
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.prevent="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="busy">Sign in</button>
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 { step, email, turnstileToken, busy, errorMessage, submit } = useForgotPassword()
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.prevent="submit(() => turnstile?.reset())">
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="busy">Send reset link</button>
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
- const { step, identity, password, code, turnstileToken, busy, errorMessage, rememberOAuthNext, submitCredentials, submitTotp, backToCredentials } =
7
- useAuthLogin()
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.prevent="submitCredentials(() => turnstile?.reset())">
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 v-model="password" type="password" autocomplete="current-password" required />
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="busy">Sign in</button>
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.prevent="submitTotp">
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="busy">Verify</button>
36
- <button type="button" :disabled="busy" @click="backToCredentials">Back</button>
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 { username, email, password, turnstileToken, busy, errorMessage, submit } = useAuthRegister()
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.prevent="submit(() => turnstile?.reset())">
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="busy">Create account</button>
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 { step, password, confirm, busy, errorMessage, submit } = usePasswordReset()
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.prevent="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="busy">Update password</button>
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
 
@@ -23,6 +23,7 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@humanonlyweb/cf-access": "0.1.2",
26
+ "@humanonlyweb/ui": "^0.7.1",
26
27
  "db0": "^0.4.2",
27
28
  "effect": "^4.1.7",
28
29
  "nuxt": "npm:nuxt-nightly@5x",
@@ -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
- export const ResetPasswordFormSchema = Schema.toStandardSchemaV1(formStruct({ password: PasswordField, confirm: Schema.String }))
56
- export const ChangeEmailFormSchema = Schema.toStandardSchemaV1(formStruct({ email: EmailField, password: NonEmptyPasswordField }))
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.1",
3
+ "version": "0.2.3",
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
- "starter",
22
- "create"
11
+ "nuxt",
12
+ "nuxt5",
13
+ "starter"
23
14
  ],
24
- "type": "module",
25
- "publishConfig": {
26
- "access": "public"
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",