Update Email Login

This commit is contained in:
Benjamin Toby 2024-07-13 11:24:36 +01:00
parent 52d4b0333d
commit 563ed6a8b3

View File

@ -107,7 +107,17 @@ async function loginLocalUser({
email_login_field
) {
const tempCode = foundUser[0][email_login_field];
isPasswordCorrect = tempCode === email_login_code;
if (!tempCode) throw new Error("No code Found!");
const tempCodeArray = tempCode.split("-");
const [code, codeDate] = tempCodeArray;
const millisecond15mins = 1000 * 60 * 15;
if (Date.now() - Number(codeDate) > millisecond15mins) {
throw new Error("Code Expired");
}
isPasswordCorrect = code === email_login_code;
}
let socialUserValid = false;