Files
TREK/client/src/utils/passwordError.ts
T
Maurice 542a57b74e feat(auth): password rules checked while typing, with the server's own policy
The password policy moves to @trek/shared, where the server keeps enforcing it unchanged and every form that sets a password now runs it before sending: the forced change after the first login, registration, the reset link, the account settings on desktop and phone, and creating or editing a user in admin. Under each new password a checklist ticks off length, upper and lower case, a number and a special character, and a refusal names the actual reason, a too common or too repetitive password included. (#1200)
2026-10-01 10:17:28 +02:00

19 lines
680 B
TypeScript

import { passwordProblem, type PasswordProblem } from '@trek/shared'
const PROBLEM_KEYS: Record<PasswordProblem, string> = {
tooShort: 'settings.passwordTooShort',
repetitive: 'settings.passwordRepetitive',
common: 'settings.passwordCommon',
weak: 'settings.passwordWeak',
}
/**
* The translation key for why a new password would be refused, or null when the
* server will take it (#1200). It runs the server's own policy from @trek/shared,
* so a form says so before the request instead of after it.
*/
export function passwordErrorKey(password: string): string | null {
const problem = passwordProblem(password)
return problem ? PROBLEM_KEYS[problem] : null
}