mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-13 08:55:48 +01:00
🐛 Fix password-requirements progress bar
This commit is contained in:
@@ -11,15 +11,19 @@ const requirements = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
function getStrength(password: string) {
|
function getStrength(password: string) {
|
||||||
let multiplier = password.length >= minPasswordLength ? 0 : 1;
|
let score = 0;
|
||||||
|
const goal = requirements.length + 1;
|
||||||
|
|
||||||
requirements.forEach((requirement) => {
|
requirements.forEach((requirement) => {
|
||||||
if (!requirement.re.test(password)) {
|
if (requirement.re.test(password)) {
|
||||||
multiplier += 1;
|
score += 1;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (password.length >= minPasswordLength) {
|
||||||
|
score += 1;
|
||||||
|
}
|
||||||
|
return (score / goal) * 100;
|
||||||
|
|
||||||
return Math.max(100 - (100 / (requirements.length + 1)) * multiplier, 10);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const PasswordRequirements = ({ value }: { value: string }) => {
|
export const PasswordRequirements = ({ value }: { value: string }) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user