@humanonlyweb/create-nuxtflare 0.2.2 → 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.
package/dist/cli.js CHANGED
@@ -6,7 +6,7 @@ import { basename as basename2, resolve as resolve2 } from "node:path";
6
6
  // package.json
7
7
  var package_default = {
8
8
  name: "@humanonlyweb/create-nuxtflare",
9
- version: "0.2.2",
9
+ version: "0.2.3",
10
10
  description: "Scaffold a Nuxt 5 + Cloudflare Workers + D1 + Effect v4 app with explicit auth, TOTP 2FA, and admin.",
11
11
  keywords: [
12
12
  "cloudflare",
@@ -6,7 +6,7 @@ import { fieldErrors, problemOf } from '~/utils/api-error'
6
6
  const mapFields = fieldErrors()
7
7
  type FormElementRef = Readonly<Ref<HTMLElement | null>>
8
8
 
9
- export const useAccount = async (
9
+ export const useAccount = (
10
10
  options: {
11
11
  readonly profileFormRef?: FormElementRef
12
12
  readonly passwordFormRef?: FormElementRef
@@ -14,16 +14,19 @@ export const useAccount = async (
14
14
  readonly deleteFormRef?: FormElementRef
15
15
  } = {},
16
16
  ) => {
17
- const { data: me, refresh: refreshMe } = await useMe()
18
17
  const features = useFeatures()
19
- const { clear, fetch: refreshSession } = useUserSession()
18
+ const { clear, fetch: refreshSession, user: sessionUser } = useUserSession()
19
+ const meFetch = useMe()
20
+ const { data: me, refresh: refreshMe } = meFetch
20
21
 
21
22
  const canUseVerifiedActions = computed(() => Boolean(me.value && (!features.emailVerificationRequired || me.value.emailStatus === 'verified')))
22
23
 
23
- const { data: sessionList, refresh: refreshSessions } = await useFetch('/api/account/sessions', {
24
- immediate: canUseVerifiedActions.value,
24
+ const initiallyVerified = Boolean(!features.emailVerificationRequired || sessionUser.value?.verified)
25
+ const sessionsFetch = useFetch('/api/account/sessions', {
26
+ immediate: initiallyVerified,
25
27
  default: () => ({ sessions: [] }),
26
28
  })
29
+ const { data: sessionList, refresh: refreshSessions } = sessionsFetch
27
30
 
28
31
  const actionBusy = ref(false)
29
32
  const notice = ref('')
@@ -63,6 +66,18 @@ export const useAccount = async (
63
66
  onError: onFormError,
64
67
  })
65
68
 
69
+ watch(
70
+ me,
71
+ (next) => {
72
+ if (next && !profile.isDirty.value) profile.setValues({ username: next.username })
73
+ },
74
+ { immediate: true },
75
+ )
76
+
77
+ watch(canUseVerifiedActions, (verified) => {
78
+ if (verified) void refreshSessions()
79
+ })
80
+
66
81
  const passwordForm = useForm({
67
82
  schema: SetPasswordFormSchema,
68
83
  initialValues: { currentPassword: '', newPassword: '', code: '' },
@@ -157,7 +172,10 @@ export const useAccount = async (
157
172
  await refreshMe()
158
173
  }, 'Pending email change cancelled.')
159
174
 
175
+ const ready = Promise.all([meFetch, sessionsFetch]).then(() => undefined)
176
+
160
177
  return {
178
+ ready,
161
179
  me,
162
180
  features,
163
181
  canUseVerifiedActions,
@@ -7,6 +7,7 @@ const emailFormRef = useTemplateRef<HTMLFormElement>('email-form')
7
7
  const deleteFormRef = useTemplateRef<HTMLFormElement>('delete-form')
8
8
 
9
9
  const {
10
+ ready,
10
11
  me,
11
12
  features,
12
13
  canUseVerifiedActions,
@@ -23,12 +24,14 @@ const {
23
24
  signOutEverywhere,
24
25
  resendVerification,
25
26
  cancelEmailChange,
26
- } = await useAccount({ profileFormRef, passwordFormRef, emailFormRef, deleteFormRef })
27
+ } = useAccount({ profileFormRef, passwordFormRef, emailFormRef, deleteFormRef })
27
28
 
28
29
  const { form: profileValues, errors: profileErrors, processing: profileProcessing, submit: saveProfile } = profile
29
30
  const { form: passwordValues, errors: passwordErrors, processing: passwordProcessing, submit: savePassword } = passwordForm
30
31
  const { form: emailValues, errors: emailErrors, processing: emailProcessing, submit: requestEmailChange } = emailForm
31
32
  const { form: deleteValues, errors: deleteErrors, processing: deleteProcessing, submit: deleteAccount } = deleteForm
33
+
34
+ await ready
32
35
  </script>
33
36
 
34
37
  <template>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@humanonlyweb/create-nuxtflare",
3
- "version": "0.2.2",
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
5
  "keywords": [
6
6
  "cloudflare",