Skip to content

Commit

Permalink
🐛 Fix bug when resetting password (fastapi#1171)
Browse files Browse the repository at this point in the history
  • Loading branch information
alejsdev authored Apr 15, 2024
1 parent ef440b9 commit e1531e4
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions frontend/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
export const emailPattern = {
value: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i,
value: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,
message: "Invalid email address",
}

export const namePattern = {
value: /^[A-Za-z\s\u00C0-\u017F]{1,30}$/,
message: "Invalid name",
}

export const passwordRules = (isRequired = true) => {
const rules: any = {
minLength: {
Expand All @@ -23,13 +28,15 @@ export const confirmPasswordRules = (
isRequired = true,
) => {
const rules: any = {
validate: (value: string) =>
value === getValues().password || "The passwords do not match",
validate: (value: string) => {
const password = getValues().password || getValues().new_password;
return value === password ? true : "The passwords do not match";
}
}

if (isRequired) {
rules.required = "Password confirmation is required"
rules.required = "Password confirmation is required";
}

return rules
return rules;
}

0 comments on commit e1531e4

Please sign in to comment.