forked from Archives/Athou_commafeed
make password match rule reusable
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
import { msg } from "@lingui/core/macro"
|
|
||||||
import { useLingui } from "@lingui/react"
|
import { useLingui } from "@lingui/react"
|
||||||
import { Trans } from "@lingui/react/macro"
|
import { Trans } from "@lingui/react/macro"
|
||||||
import { Anchor, Box, Button, Checkbox, Divider, Group, Input, PasswordInput, Stack, Text, TextInput } from "@mantine/core"
|
import { Anchor, Box, Button, Checkbox, Divider, Group, Input, PasswordInput, Stack, Text, TextInput } from "@mantine/core"
|
||||||
@@ -29,7 +28,7 @@ export function ProfileSettings() {
|
|||||||
const form = useForm<FormData>({
|
const form = useForm<FormData>({
|
||||||
validate: {
|
validate: {
|
||||||
newPassword: validationRules.password,
|
newPassword: validationRules.password,
|
||||||
newPasswordConfirmation: (value, values) => (value !== values.newPassword ? _(msg`Passwords do not match`) : null),
|
newPasswordConfirmation: (value, values) => validationRules.passwordConfirmation(value, values.newPassword),
|
||||||
},
|
},
|
||||||
validateInputOnChange: true,
|
validateInputOnChange: true,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -11,5 +11,7 @@ export function useValidationRules() {
|
|||||||
value && minimumPasswordLength && value.length < minimumPasswordLength
|
value && minimumPasswordLength && value.length < minimumPasswordLength
|
||||||
? _(msg`Password must be at least ${minimumPasswordLength} characters`)
|
? _(msg`Password must be at least ${minimumPasswordLength} characters`)
|
||||||
: null,
|
: null,
|
||||||
|
passwordConfirmation: (newPasswordConfirmation: string | undefined, newPassword: string | undefined) =>
|
||||||
|
newPasswordConfirmation && newPasswordConfirmation !== newPassword ? _(msg`Passwords do not match`) : null,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -794,8 +794,7 @@ msgstr ""
|
|||||||
msgid "Password Recovery"
|
msgid "Password Recovery"
|
||||||
msgstr "استعادة كلمة المرور"
|
msgstr "استعادة كلمة المرور"
|
||||||
|
|
||||||
#: src/components/settings/ProfileSettings.tsx
|
#: src/hooks/useValidationRules.ts
|
||||||
#: src/pages/auth/PasswordResetPage.tsx
|
|
||||||
msgid "Passwords do not match"
|
msgid "Passwords do not match"
|
||||||
msgstr "كلمات المرور غير متطابقة"
|
msgstr "كلمات المرور غير متطابقة"
|
||||||
|
|
||||||
|
|||||||
@@ -794,8 +794,7 @@ msgstr ""
|
|||||||
msgid "Password Recovery"
|
msgid "Password Recovery"
|
||||||
msgstr "Recuperació de contrasenya"
|
msgstr "Recuperació de contrasenya"
|
||||||
|
|
||||||
#: src/components/settings/ProfileSettings.tsx
|
#: src/hooks/useValidationRules.ts
|
||||||
#: src/pages/auth/PasswordResetPage.tsx
|
|
||||||
msgid "Passwords do not match"
|
msgid "Passwords do not match"
|
||||||
msgstr "Les contrasenyes no coincideixen"
|
msgstr "Les contrasenyes no coincideixen"
|
||||||
|
|
||||||
|
|||||||
@@ -794,8 +794,7 @@ msgstr ""
|
|||||||
msgid "Password Recovery"
|
msgid "Password Recovery"
|
||||||
msgstr "Obnovení hesla"
|
msgstr "Obnovení hesla"
|
||||||
|
|
||||||
#: src/components/settings/ProfileSettings.tsx
|
#: src/hooks/useValidationRules.ts
|
||||||
#: src/pages/auth/PasswordResetPage.tsx
|
|
||||||
msgid "Passwords do not match"
|
msgid "Passwords do not match"
|
||||||
msgstr "Hesla se neshodují"
|
msgstr "Hesla se neshodují"
|
||||||
|
|
||||||
|
|||||||
@@ -794,8 +794,7 @@ msgstr ""
|
|||||||
msgid "Password Recovery"
|
msgid "Password Recovery"
|
||||||
msgstr "Adfer Cyfrinair"
|
msgstr "Adfer Cyfrinair"
|
||||||
|
|
||||||
#: src/components/settings/ProfileSettings.tsx
|
#: src/hooks/useValidationRules.ts
|
||||||
#: src/pages/auth/PasswordResetPage.tsx
|
|
||||||
msgid "Passwords do not match"
|
msgid "Passwords do not match"
|
||||||
msgstr "Nid yw cyfrineiriau yn cyfateb"
|
msgstr "Nid yw cyfrineiriau yn cyfateb"
|
||||||
|
|
||||||
|
|||||||
@@ -794,8 +794,7 @@ msgstr ""
|
|||||||
msgid "Password Recovery"
|
msgid "Password Recovery"
|
||||||
msgstr "Gendannelse af adgangskode"
|
msgstr "Gendannelse af adgangskode"
|
||||||
|
|
||||||
#: src/components/settings/ProfileSettings.tsx
|
#: src/hooks/useValidationRules.ts
|
||||||
#: src/pages/auth/PasswordResetPage.tsx
|
|
||||||
msgid "Passwords do not match"
|
msgid "Passwords do not match"
|
||||||
msgstr "Adgangskoder stemmer ikke overens"
|
msgstr "Adgangskoder stemmer ikke overens"
|
||||||
|
|
||||||
|
|||||||
@@ -794,8 +794,7 @@ msgstr ""
|
|||||||
msgid "Password Recovery"
|
msgid "Password Recovery"
|
||||||
msgstr "Passwortwiederherstellung"
|
msgstr "Passwortwiederherstellung"
|
||||||
|
|
||||||
#: src/components/settings/ProfileSettings.tsx
|
#: src/hooks/useValidationRules.ts
|
||||||
#: src/pages/auth/PasswordResetPage.tsx
|
|
||||||
msgid "Passwords do not match"
|
msgid "Passwords do not match"
|
||||||
msgstr "Passwörter stimmen nicht überein"
|
msgstr "Passwörter stimmen nicht überein"
|
||||||
|
|
||||||
|
|||||||
@@ -794,8 +794,7 @@ msgstr "Password must be at least {minimumPasswordLength} characters"
|
|||||||
msgid "Password Recovery"
|
msgid "Password Recovery"
|
||||||
msgstr "Password Recovery"
|
msgstr "Password Recovery"
|
||||||
|
|
||||||
#: src/components/settings/ProfileSettings.tsx
|
#: src/hooks/useValidationRules.ts
|
||||||
#: src/pages/auth/PasswordResetPage.tsx
|
|
||||||
msgid "Passwords do not match"
|
msgid "Passwords do not match"
|
||||||
msgstr "Passwords do not match"
|
msgstr "Passwords do not match"
|
||||||
|
|
||||||
|
|||||||
@@ -795,8 +795,7 @@ msgstr ""
|
|||||||
msgid "Password Recovery"
|
msgid "Password Recovery"
|
||||||
msgstr "Recuperación de contraseña"
|
msgstr "Recuperación de contraseña"
|
||||||
|
|
||||||
#: src/components/settings/ProfileSettings.tsx
|
#: src/hooks/useValidationRules.ts
|
||||||
#: src/pages/auth/PasswordResetPage.tsx
|
|
||||||
msgid "Passwords do not match"
|
msgid "Passwords do not match"
|
||||||
msgstr "Las contraseñas no coinciden"
|
msgstr "Las contraseñas no coinciden"
|
||||||
|
|
||||||
|
|||||||
@@ -794,8 +794,7 @@ msgstr ""
|
|||||||
msgid "Password Recovery"
|
msgid "Password Recovery"
|
||||||
msgstr "بازیابی رمز عبور"
|
msgstr "بازیابی رمز عبور"
|
||||||
|
|
||||||
#: src/components/settings/ProfileSettings.tsx
|
#: src/hooks/useValidationRules.ts
|
||||||
#: src/pages/auth/PasswordResetPage.tsx
|
|
||||||
msgid "Passwords do not match"
|
msgid "Passwords do not match"
|
||||||
msgstr "گذرواژه ها مطابقت ندارند"
|
msgstr "گذرواژه ها مطابقت ندارند"
|
||||||
|
|
||||||
|
|||||||
@@ -794,8 +794,7 @@ msgstr ""
|
|||||||
msgid "Password Recovery"
|
msgid "Password Recovery"
|
||||||
msgstr "Salasanan palautus"
|
msgstr "Salasanan palautus"
|
||||||
|
|
||||||
#: src/components/settings/ProfileSettings.tsx
|
#: src/hooks/useValidationRules.ts
|
||||||
#: src/pages/auth/PasswordResetPage.tsx
|
|
||||||
msgid "Passwords do not match"
|
msgid "Passwords do not match"
|
||||||
msgstr "Salasanat eivät täsmää"
|
msgstr "Salasanat eivät täsmää"
|
||||||
|
|
||||||
|
|||||||
@@ -794,8 +794,7 @@ msgstr ""
|
|||||||
msgid "Password Recovery"
|
msgid "Password Recovery"
|
||||||
msgstr "Récupération de mot de passe"
|
msgstr "Récupération de mot de passe"
|
||||||
|
|
||||||
#: src/components/settings/ProfileSettings.tsx
|
#: src/hooks/useValidationRules.ts
|
||||||
#: src/pages/auth/PasswordResetPage.tsx
|
|
||||||
msgid "Passwords do not match"
|
msgid "Passwords do not match"
|
||||||
msgstr "Les mots de passe ne correspondent pas"
|
msgstr "Les mots de passe ne correspondent pas"
|
||||||
|
|
||||||
|
|||||||
@@ -795,8 +795,7 @@ msgstr ""
|
|||||||
msgid "Password Recovery"
|
msgid "Password Recovery"
|
||||||
msgstr "Recuperación do contrasinal"
|
msgstr "Recuperación do contrasinal"
|
||||||
|
|
||||||
#: src/components/settings/ProfileSettings.tsx
|
#: src/hooks/useValidationRules.ts
|
||||||
#: src/pages/auth/PasswordResetPage.tsx
|
|
||||||
msgid "Passwords do not match"
|
msgid "Passwords do not match"
|
||||||
msgstr "Os contrasinais non coinciden"
|
msgstr "Os contrasinais non coinciden"
|
||||||
|
|
||||||
|
|||||||
@@ -794,8 +794,7 @@ msgstr ""
|
|||||||
msgid "Password Recovery"
|
msgid "Password Recovery"
|
||||||
msgstr "Jelszó helyreállítás"
|
msgstr "Jelszó helyreállítás"
|
||||||
|
|
||||||
#: src/components/settings/ProfileSettings.tsx
|
#: src/hooks/useValidationRules.ts
|
||||||
#: src/pages/auth/PasswordResetPage.tsx
|
|
||||||
msgid "Passwords do not match"
|
msgid "Passwords do not match"
|
||||||
msgstr "A jelszavak nem egyeznek"
|
msgstr "A jelszavak nem egyeznek"
|
||||||
|
|
||||||
|
|||||||
@@ -794,8 +794,7 @@ msgstr ""
|
|||||||
msgid "Password Recovery"
|
msgid "Password Recovery"
|
||||||
msgstr "Pemulihan Kata Sandi"
|
msgstr "Pemulihan Kata Sandi"
|
||||||
|
|
||||||
#: src/components/settings/ProfileSettings.tsx
|
#: src/hooks/useValidationRules.ts
|
||||||
#: src/pages/auth/PasswordResetPage.tsx
|
|
||||||
msgid "Passwords do not match"
|
msgid "Passwords do not match"
|
||||||
msgstr "Kata sandi tidak cocok"
|
msgstr "Kata sandi tidak cocok"
|
||||||
|
|
||||||
|
|||||||
@@ -794,8 +794,7 @@ msgstr ""
|
|||||||
msgid "Password Recovery"
|
msgid "Password Recovery"
|
||||||
msgstr "Recupero password"
|
msgstr "Recupero password"
|
||||||
|
|
||||||
#: src/components/settings/ProfileSettings.tsx
|
#: src/hooks/useValidationRules.ts
|
||||||
#: src/pages/auth/PasswordResetPage.tsx
|
|
||||||
msgid "Passwords do not match"
|
msgid "Passwords do not match"
|
||||||
msgstr "Le password non corrispondono"
|
msgstr "Le password non corrispondono"
|
||||||
|
|
||||||
|
|||||||
@@ -794,8 +794,7 @@ msgstr ""
|
|||||||
msgid "Password Recovery"
|
msgid "Password Recovery"
|
||||||
msgstr "パスワード回復"
|
msgstr "パスワード回復"
|
||||||
|
|
||||||
#: src/components/settings/ProfileSettings.tsx
|
#: src/hooks/useValidationRules.ts
|
||||||
#: src/pages/auth/PasswordResetPage.tsx
|
|
||||||
msgid "Passwords do not match"
|
msgid "Passwords do not match"
|
||||||
msgstr "パスワードが一致しません"
|
msgstr "パスワードが一致しません"
|
||||||
|
|
||||||
|
|||||||
@@ -794,8 +794,7 @@ msgstr ""
|
|||||||
msgid "Password Recovery"
|
msgid "Password Recovery"
|
||||||
msgstr "비밀번호 복구"
|
msgstr "비밀번호 복구"
|
||||||
|
|
||||||
#: src/components/settings/ProfileSettings.tsx
|
#: src/hooks/useValidationRules.ts
|
||||||
#: src/pages/auth/PasswordResetPage.tsx
|
|
||||||
msgid "Passwords do not match"
|
msgid "Passwords do not match"
|
||||||
msgstr "비밀번호가 일치하지 않습니다"
|
msgstr "비밀번호가 일치하지 않습니다"
|
||||||
|
|
||||||
|
|||||||
@@ -794,8 +794,7 @@ msgstr ""
|
|||||||
msgid "Password Recovery"
|
msgid "Password Recovery"
|
||||||
msgstr "Pemulihan Kata Laluan"
|
msgstr "Pemulihan Kata Laluan"
|
||||||
|
|
||||||
#: src/components/settings/ProfileSettings.tsx
|
#: src/hooks/useValidationRules.ts
|
||||||
#: src/pages/auth/PasswordResetPage.tsx
|
|
||||||
msgid "Passwords do not match"
|
msgid "Passwords do not match"
|
||||||
msgstr "Kata laluan tidak sepadan"
|
msgstr "Kata laluan tidak sepadan"
|
||||||
|
|
||||||
|
|||||||
@@ -794,8 +794,7 @@ msgstr ""
|
|||||||
msgid "Password Recovery"
|
msgid "Password Recovery"
|
||||||
msgstr "Passordgjenoppretting"
|
msgstr "Passordgjenoppretting"
|
||||||
|
|
||||||
#: src/components/settings/ProfileSettings.tsx
|
#: src/hooks/useValidationRules.ts
|
||||||
#: src/pages/auth/PasswordResetPage.tsx
|
|
||||||
msgid "Passwords do not match"
|
msgid "Passwords do not match"
|
||||||
msgstr "Passordene samsvarer ikke"
|
msgstr "Passordene samsvarer ikke"
|
||||||
|
|
||||||
|
|||||||
@@ -794,8 +794,7 @@ msgstr ""
|
|||||||
msgid "Password Recovery"
|
msgid "Password Recovery"
|
||||||
msgstr "Wachtwoordherstel"
|
msgstr "Wachtwoordherstel"
|
||||||
|
|
||||||
#: src/components/settings/ProfileSettings.tsx
|
#: src/hooks/useValidationRules.ts
|
||||||
#: src/pages/auth/PasswordResetPage.tsx
|
|
||||||
msgid "Passwords do not match"
|
msgid "Passwords do not match"
|
||||||
msgstr "Wachtwoorden komen niet overeen"
|
msgstr "Wachtwoorden komen niet overeen"
|
||||||
|
|
||||||
|
|||||||
@@ -794,8 +794,7 @@ msgstr ""
|
|||||||
msgid "Password Recovery"
|
msgid "Password Recovery"
|
||||||
msgstr "Passordgjenoppretting"
|
msgstr "Passordgjenoppretting"
|
||||||
|
|
||||||
#: src/components/settings/ProfileSettings.tsx
|
#: src/hooks/useValidationRules.ts
|
||||||
#: src/pages/auth/PasswordResetPage.tsx
|
|
||||||
msgid "Passwords do not match"
|
msgid "Passwords do not match"
|
||||||
msgstr "Passordene samsvarer ikke"
|
msgstr "Passordene samsvarer ikke"
|
||||||
|
|
||||||
|
|||||||
@@ -794,8 +794,7 @@ msgstr ""
|
|||||||
msgid "Password Recovery"
|
msgid "Password Recovery"
|
||||||
msgstr "Odzyskiwanie hasła"
|
msgstr "Odzyskiwanie hasła"
|
||||||
|
|
||||||
#: src/components/settings/ProfileSettings.tsx
|
#: src/hooks/useValidationRules.ts
|
||||||
#: src/pages/auth/PasswordResetPage.tsx
|
|
||||||
msgid "Passwords do not match"
|
msgid "Passwords do not match"
|
||||||
msgstr "Hasła nie pasują"
|
msgstr "Hasła nie pasują"
|
||||||
|
|
||||||
|
|||||||
@@ -794,8 +794,7 @@ msgstr ""
|
|||||||
msgid "Password Recovery"
|
msgid "Password Recovery"
|
||||||
msgstr "Recuperação de Senha"
|
msgstr "Recuperação de Senha"
|
||||||
|
|
||||||
#: src/components/settings/ProfileSettings.tsx
|
#: src/hooks/useValidationRules.ts
|
||||||
#: src/pages/auth/PasswordResetPage.tsx
|
|
||||||
msgid "Passwords do not match"
|
msgid "Passwords do not match"
|
||||||
msgstr "Senhas não coincidem"
|
msgstr "Senhas não coincidem"
|
||||||
|
|
||||||
|
|||||||
@@ -794,8 +794,7 @@ msgstr ""
|
|||||||
msgid "Password Recovery"
|
msgid "Password Recovery"
|
||||||
msgstr "Восстановление пароля"
|
msgstr "Восстановление пароля"
|
||||||
|
|
||||||
#: src/components/settings/ProfileSettings.tsx
|
#: src/hooks/useValidationRules.ts
|
||||||
#: src/pages/auth/PasswordResetPage.tsx
|
|
||||||
msgid "Passwords do not match"
|
msgid "Passwords do not match"
|
||||||
msgstr "Пароли не совпадают"
|
msgstr "Пароли не совпадают"
|
||||||
|
|
||||||
|
|||||||
@@ -794,8 +794,7 @@ msgstr ""
|
|||||||
msgid "Password Recovery"
|
msgid "Password Recovery"
|
||||||
msgstr "Obnovenie hesla"
|
msgstr "Obnovenie hesla"
|
||||||
|
|
||||||
#: src/components/settings/ProfileSettings.tsx
|
#: src/hooks/useValidationRules.ts
|
||||||
#: src/pages/auth/PasswordResetPage.tsx
|
|
||||||
msgid "Passwords do not match"
|
msgid "Passwords do not match"
|
||||||
msgstr "Heslá sa nezhodujú"
|
msgstr "Heslá sa nezhodujú"
|
||||||
|
|
||||||
|
|||||||
@@ -794,8 +794,7 @@ msgstr ""
|
|||||||
msgid "Password Recovery"
|
msgid "Password Recovery"
|
||||||
msgstr "Lösenordsåterställning"
|
msgstr "Lösenordsåterställning"
|
||||||
|
|
||||||
#: src/components/settings/ProfileSettings.tsx
|
#: src/hooks/useValidationRules.ts
|
||||||
#: src/pages/auth/PasswordResetPage.tsx
|
|
||||||
msgid "Passwords do not match"
|
msgid "Passwords do not match"
|
||||||
msgstr "Lösenorden matchar inte"
|
msgstr "Lösenorden matchar inte"
|
||||||
|
|
||||||
|
|||||||
@@ -794,8 +794,7 @@ msgstr ""
|
|||||||
msgid "Password Recovery"
|
msgid "Password Recovery"
|
||||||
msgstr "Parola Kurtarma"
|
msgstr "Parola Kurtarma"
|
||||||
|
|
||||||
#: src/components/settings/ProfileSettings.tsx
|
#: src/hooks/useValidationRules.ts
|
||||||
#: src/pages/auth/PasswordResetPage.tsx
|
|
||||||
msgid "Passwords do not match"
|
msgid "Passwords do not match"
|
||||||
msgstr "Parolalar eşleşmiyor"
|
msgstr "Parolalar eşleşmiyor"
|
||||||
|
|
||||||
|
|||||||
@@ -794,8 +794,7 @@ msgstr "密码最少需要 {minimumPasswordLength} 个字符"
|
|||||||
msgid "Password Recovery"
|
msgid "Password Recovery"
|
||||||
msgstr "密码恢复"
|
msgstr "密码恢复"
|
||||||
|
|
||||||
#: src/components/settings/ProfileSettings.tsx
|
#: src/hooks/useValidationRules.ts
|
||||||
#: src/pages/auth/PasswordResetPage.tsx
|
|
||||||
msgid "Passwords do not match"
|
msgid "Passwords do not match"
|
||||||
msgstr "密码不匹配"
|
msgstr "密码不匹配"
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export function PasswordResetPage() {
|
|||||||
},
|
},
|
||||||
validate: {
|
validate: {
|
||||||
password: validationRules.password,
|
password: validationRules.password,
|
||||||
passwordConfirmation: (value, values) => (value === values.password ? null : _(msg`Passwords do not match`)),
|
passwordConfirmation: (value, values) => validationRules.passwordConfirmation(value, values.password),
|
||||||
},
|
},
|
||||||
validateInputOnChange: true,
|
validateInputOnChange: true,
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user