This commit is contained in:
Holly Stubbs 2022-11-19 14:46:40 +00:00
parent 2beeb5fd09
commit a09543b2fb
Signed by: tgpholly
GPG key ID: B8583C4B7D18119E

View file

@ -68,17 +68,8 @@ function TestLogin(loginInfo:LoginInfo | undefined, database:Database) {
1: Old MD5 password 1: Old MD5 password
2: Old AES password 2: Old AES password
*/ */
if (userDBData.has_old_password === LoginTypes.OLD_MD5) { switch (userDBData.has_old_password) {
if (userDBData.password_hash !== loginInfo.password) case LoginTypes.CURRENT:
return resolve(incorrectLoginResponse());
return resolve(requiredPWChangeResponse());
} else if (userDBData.has_old_password === LoginTypes.OLD_AES) {
if (aesDecrypt(config.database.key, userDBData.password_hash) !== loginInfo.password)
return resolve(resolve(incorrectLoginResponse()));
return resolve(requiredPWChangeResponse());
} else {
pbkdf2(loginInfo.password, userDBData.password_salt, config.database.pbkdf2.itterations, config.database.pbkdf2.keylength, "sha512", (err, derivedKey) => { pbkdf2(loginInfo.password, userDBData.password_salt, config.database.pbkdf2.itterations, config.database.pbkdf2.keylength, "sha512", (err, derivedKey) => {
if (err) { if (err) {
return reject(err); return reject(err);
@ -89,6 +80,17 @@ function TestLogin(loginInfo:LoginInfo | undefined, database:Database) {
return resolve(undefined); // We good return resolve(undefined); // We good
} }
}); });
break;
case LoginTypes.OLD_AES:
if (aesDecrypt(config.database.key, userDBData.password_hash) !== loginInfo.password) {
return resolve(resolve(incorrectLoginResponse()));
}
return resolve(requiredPWChangeResponse());
case LoginTypes.OLD_MD5:
if (userDBData.password_hash !== loginInfo.password) {
return resolve(incorrectLoginResponse());
}
return resolve(requiredPWChangeResponse());
} }
}); });
} }