fix(dashboard-v2): bulletproof emptying one's email address

This commit is contained in:
Michał Leszczyk 2022-03-25 12:54:59 +01:00
parent 07112383d3
commit 5231413074
No known key found for this signature in database
GPG Key ID: FA123CA8BAA2FBF4
1 changed files with 5 additions and 2 deletions

View File

@ -16,7 +16,7 @@ const emailUpdateSchema = Yup.object().shape({
is: isPopulated, is: isPopulated,
then: (schema) => schema.required("Please confirm new email address"), then: (schema) => schema.required("Please confirm new email address"),
}), }),
password: Yup.string().min(6, "Password has to be at least 6 characters long"), password: Yup.string().min(1, "Password can't be blank"),
confirmPassword: Yup.string() confirmPassword: Yup.string()
.oneOf([Yup.ref("password"), null], "Passwords must match") .oneOf([Yup.ref("password"), null], "Passwords must match")
.when("password", { .when("password", {
@ -38,7 +38,10 @@ export const AccountSettingsForm = ({ user, onSuccess, onFailure }) => {
onSubmit={async ({ email, password }, { resetForm }) => { onSubmit={async ({ email, password }, { resetForm }) => {
try { try {
await accountsService.put("user", { await accountsService.put("user", {
json: { email, password }, json: {
email: email || undefined,
password: password || undefined,
},
}); });
resetForm(); resetForm();