mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-30 08:30:05 +00:00
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)
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user