enforcing strong passwords when changing password

This commit is contained in:
Miodec 2022-09-28 12:43:39 +02:00
parent b26348fcce
commit 8bf5d451bd

View file

@ -20,6 +20,7 @@ import {
unlink,
updatePassword,
} from "firebase/auth";
import { isPasswordStrong } from "../utils/misc";
interface Input {
placeholder?: string;
@ -524,6 +525,17 @@ list["updatePassword"] = new SimplePopup(
Notifications.add("New passwords don't match", 0);
return;
}
if (
window.location.hostname !== "localhost" &&
!isPasswordStrong(newPass)
) {
Notifications.add(
"New password must contain at least one capital letter, number, a special character and at least 8 characters long",
0,
4
);
return;
}
Loader.show();
await reauthenticateWithCredential(user, credential);
await updatePassword(user, newPass);