@@ -54,11 +54,8 @@ import { useStore } from '../../store/index.js'
5454import { formDataKey } from ' ./injectionKeys.ts'
5555
5656const props = defineProps <{
57- /** Shared loading flags owned by UserList */
5857 loading: { all: boolean }
59- /** The reactive new-user form state owned by UserList */
6058 newUser: FormData
61- /** Quota preset options for the quota select */
6259 quotaOptions: QuotaOption []
6360}>()
6461
@@ -68,11 +65,10 @@ const emit = defineEmits<{
6865
6966const store = useStore ()
7067
71- /** Template ref to UserFormFields, used to focus a field on mount / on error */
7268const fields = ref <{ focusField: (name : ' username' | ' password' ) => void } | null >(null )
7369
74- // Children inject this reactive object and mutate its properties via v-model.
75- // Do not reassign newUser entirely, the injected reference would go stale.
70+ // Children inject and mutate this object's properties; never reassign it or the
71+ // injected reference goes stale.
7672provide (formDataKey , props .newUser )
7773
7874const settings = computed (() => store .getters .getServerData )
@@ -81,11 +77,6 @@ const usernameLabel = computed(() => settings.value.newUserGenerateUserID
8177 ? t (' settings' , ' Account name will be autogenerated' )
8278 : t (' settings' , ' Account name (required)' ))
8379
84- /**
85- * Reactive field configuration passed to UserFormFields.
86- * Controls visibility, labels, and required state for each field
87- * based on the current form values and server settings.
88- */
8980const fieldConfig = computed (() => ({
9081 username: {
9182 show: true ,
@@ -116,8 +107,7 @@ const fieldConfig = computed(() => ({
116107onMounted (() => fields .value ?.focusField (' username' ))
117108
118109/**
119- * Create the account from the current form state. On a known 4xx, focus the
120- * offending field (102 = username taken, 107 = password policy).
110+ * Create the account from the current form state.
121111 */
122112async function createUser() {
123113 // Guard against re-submit while a request is already running. The
@@ -146,8 +136,10 @@ async function createUser() {
146136 .response ?.data ?.ocs ?.meta
147137 if (meta ) {
148138 if (meta .statuscode === 102 ) {
139+ // Username already taken.
149140 fields .value ?.focusField (' username' )
150141 } else if (meta .statuscode === 107 ) {
142+ // Password policy rejected.
151143 fields .value ?.focusField (' password' )
152144 }
153145 }
0 commit comments