switch
This commit is contained in:
parent
2beeb5fd09
commit
a09543b2fb
1 changed files with 22 additions and 20 deletions
|
@ -68,27 +68,29 @@ 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());
|
pbkdf2(loginInfo.password, userDBData.password_salt, config.database.pbkdf2.itterations, config.database.pbkdf2.keylength, "sha512", (err, derivedKey) => {
|
||||||
|
if (err) {
|
||||||
return resolve(requiredPWChangeResponse());
|
return reject(err);
|
||||||
} else if (userDBData.has_old_password === LoginTypes.OLD_AES) {
|
} else {
|
||||||
if (aesDecrypt(config.database.key, userDBData.password_hash) !== loginInfo.password)
|
if (derivedKey.toString("hex") !== userDBData.password_hash)
|
||||||
return resolve(resolve(incorrectLoginResponse()));
|
return resolve(incorrectLoginResponse());
|
||||||
|
|
||||||
return resolve(requiredPWChangeResponse());
|
return resolve(undefined); // We good
|
||||||
} else {
|
}
|
||||||
pbkdf2(loginInfo.password, userDBData.password_salt, config.database.pbkdf2.itterations, config.database.pbkdf2.keylength, "sha512", (err, derivedKey) => {
|
});
|
||||||
if (err) {
|
break;
|
||||||
return reject(err);
|
case LoginTypes.OLD_AES:
|
||||||
} else {
|
if (aesDecrypt(config.database.key, userDBData.password_hash) !== loginInfo.password) {
|
||||||
if (derivedKey.toString("hex") !== userDBData.password_hash)
|
return resolve(resolve(incorrectLoginResponse()));
|
||||||
return resolve(incorrectLoginResponse());
|
|
||||||
|
|
||||||
return resolve(undefined); // We good
|
|
||||||
}
|
}
|
||||||
});
|
return resolve(requiredPWChangeResponse());
|
||||||
|
case LoginTypes.OLD_MD5:
|
||||||
|
if (userDBData.password_hash !== loginInfo.password) {
|
||||||
|
return resolve(incorrectLoginResponse());
|
||||||
|
}
|
||||||
|
return resolve(requiredPWChangeResponse());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue