Fix throwing unhandled promise rejection if user doesn't exist in validatePasswordRedirect user to /profile on successful login

This commit is contained in:
knotteye
2019-12-05 15:03:27 -06:00
parent be38b873eb
commit 8c17149f39
2 changed files with 15 additions and 4 deletions

View File

@ -45,8 +45,12 @@ async function query(query: string){
}
async function validatePassword(username: string, password: string){
let pass: any = await query('select password_hash from users where username='+raw.escape(username)+' limit 1');
return await bcrypt.compare(password, pass[0].password_hash.toString());
try {
let pass: any = await query('select password_hash from users where username='+raw.escape(username)+' limit 1');
return await bcrypt.compare(password, pass[0].password_hash.toString());
} catch(e) {
return false;
}
}
async function hash(pwd){