mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-19 13:36:48 +00:00
542a57b74e
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)
19 lines
680 B
TypeScript
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
|
|
}
|