(pw: string)
| 46 | "changeme", "abcdefgh", |
| 47 | ]) |
| 48 | function validatePasswordStrength(pw: string): string | null { |
| 49 | if (pw.length < 10) { |
| 50 | return "Password must be at least 10 characters" |
| 51 | } |
| 52 | const categories = [ |
| 53 | /[a-z]/.test(pw), |
| 54 | /[A-Z]/.test(pw), |
| 55 | /\d/.test(pw), |
| 56 | /[^A-Za-z0-9]/.test(pw), |
| 57 | ].filter(Boolean).length |
| 58 | if (categories < 3) { |
| 59 | return "Password must mix at least 3 of: lowercase, uppercase, digits, symbols" |
| 60 | } |
| 61 | if (_OBVIOUS_PASSWORDS.has(pw.toLowerCase())) { |
| 62 | return "That password is in the common-passwords list — pick something else" |
| 63 | } |
| 64 | return null |
| 65 | } |
| 66 | |
| 67 | export function Security() { |
| 68 | const [authEnabled, setAuthEnabled] = useState(false) |
no test coverage detected