Closed xgp closed 1 year ago
Look at https://github.com/p2-inc/phasetwo-admin-portal/issues/81 in conjunction with fixing this.
featureFlags.registrationEmailAsUsername
we're using this to decide whether or not to show the "username" right now, but I don't think that logic is right then.
{!featureFlags.registrationEmailAsUsername && (
<RHFFormTextInputWithLabel
slug="username"
label={t("username")}
register={register}
registerArgs={{
required: true,
pattern: /\S+@\S+\.\S+/,
}}
inputArgs={{
disabled: isLoadingAccount || !featureFlags.editUsernameAllowed,
placeholder: "you",
type: "username",
}}
error={errors.username}
/>
)}
<RHFFormTextInputWithLabel
slug="email"
label={t("email")}
register={register}
registerArgs={{
required: true,
pattern: /\S+@\S+\.\S+/,
}}
inputArgs={{
disabled:
isLoadingAccount || !featureFlags.updateEmailFeatureEnabled,
placeholder: "your@email.com",
type: "email",
}}
error={errors.email}
/>
I think the logic needs to be
registrationEmailAsUsername
is true, show a "Username / Email" form field. Only update the "username" though in this case. I think trying to set the email
field when registrationEmailAsUsername
might cause drift between username
and email
and you want them to stay in lockstep. I did this, the form validates (in browser) for a valid email. registrationEmailAsUsername
is false, then show both username
and email
fields. Can we be sure username
is set at this point? Should the form require it?
Email doesn't get set when "email as username" is used. This appears to be a problem with the user
account
APIAs a workaround, maybe we should look in the username for a valid email if an
email
field is not present.