validate password in the frontend too (#2017)

This commit is contained in:
Athou
2026-01-15 09:44:57 +01:00
parent eb573fdc8b
commit 5a95b95801
36 changed files with 223 additions and 125 deletions

View File

@@ -6,12 +6,13 @@ import { useForm } from "@mantine/form"
import { useAsyncCallback } from "react-async-hook"
import { client, errorToStrings } from "@/app/client"
import { redirectToRootCategory } from "@/app/redirect/thunks"
import { useAppDispatch } from "@/app/store"
import { useAppDispatch, useAppSelector } from "@/app/store"
import type { InitialSetupRequest } from "@/app/types"
import { Alert } from "@/components/Alert"
import { PageTitle } from "@/pages/PageTitle"
export function InitialSetupPage() {
const serverInfos = useAppSelector(state => state.server.serverInfos)
const dispatch = useAppDispatch()
const { _ } = useLingui()
@@ -21,6 +22,13 @@ export function InitialSetupPage() {
password: "",
email: "",
},
validate: {
password: value =>
serverInfos && value.length < serverInfos.minimumPasswordLength
? _(msg`Password must be at least ${serverInfos.minimumPasswordLength} characters`)
: null,
},
validateInputOnChange: true,
})
const login = useAsyncCallback(client.user.login, {

View File

@@ -23,6 +23,13 @@ export function RegistrationPage() {
password: "",
email: "",
},
validate: {
password: value =>
serverInfos && value.length < serverInfos.minimumPasswordLength
? _(msg`Password must be at least ${serverInfos.minimumPasswordLength} characters`)
: null,
},
validateInputOnChange: true,
})
const login = useAsyncCallback(client.user.login, {