Don't return admin_min error when we're not validating for admin password. (#5713)

pull/5726/head^2
Jeroen Reumkens 2022-11-28 15:57:02 +01:00 committed by GitHub
parent 0ef80da260
commit 2ce2c1074b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -54,7 +54,14 @@ export function isPasswordValid(password: string, breakdown?: boolean, strict?:
if (password[i] === password[i].toLowerCase()) low = true;
}
}
return !!breakdown ? { caplow: cap && low, num, min, admin_min } : cap && low && num && min;
if (!breakdown) return cap && low && num && min && (strict ? admin_min : true);
let errors: Record<string, boolean> = { caplow: cap && low, num, min };
// Only return the admin key if strict mode is enabled.
if (strict) errors = { ...errors, admin_min };
return errors;
}
type CtxOrReq = { req: NextApiRequest; ctx?: never } | { ctx: { req: NextApiRequest }; req?: never };