fix: improve password validation flow (#15132)

Refers to #14984 

Currently, password validation is done backend side and is not explicit
enough so it can be painful to create first users.
We'd like to make this validation easier - but also duplicate it
frontend side to make it smoother.

Flows involved : 
- First user set password
- New user set password
- Change password

---------

Co-authored-by: BrunoQuaresma <bruno_nonato_quaresma@hotmail.com>
This commit is contained in:
Vincent Vielle
2024-11-05 17:22:32 +01:00
committed by GitHub
parent 8b5a18cade
commit 4fe2c5f09a
21 changed files with 530 additions and 74 deletions

View File

@ -6,9 +6,10 @@ import type * as TypesGen from "api/typesGenerated";
import { ErrorAlert } from "components/Alert/ErrorAlert";
import { FormFooter } from "components/FormFooter/FormFooter";
import { FullPageForm } from "components/FullPageForm/FullPageForm";
import { PasswordField } from "components/PasswordField/PasswordField";
import { Stack } from "components/Stack/Stack";
import { type FormikContextType, useFormik } from "formik";
import type { FC } from "react";
import { type FC, useEffect } from "react";
import {
displayNameValidator,
getFormHelpers,
@ -186,7 +187,7 @@ export const CreateUserForm: FC<
);
})}
</TextField>
<TextField
<PasswordField
{...getFieldHelpers("password", {
helperText:
form.values.login_type !== "password" &&
@ -198,7 +199,6 @@ export const CreateUserForm: FC<
data-testid="password-input"
disabled={form.values.login_type !== "password"}
label={Language.passwordLabel}
type="password"
/>
</Stack>
<FormFooter