fix(auth): handle sign-in attempts from emails with no password (#933)

* fix(auth): dont reject promise when missing password

* fix(auth): use static fallback error message
pull/910/head
Jakob Ankarhem 3 years ago committed by GitHub
parent 8a7fa00164
commit 5e37a96bc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -108,11 +108,11 @@ export class User {
}
public passwordMatch(password: string): Promise<boolean> {
return new Promise((resolve, reject) => {
return new Promise((resolve) => {
if (this.password) {
resolve(bcrypt.compare(password, this.password));
} else {
return reject(false);
return resolve(false);
}
});
}

@ -176,7 +176,10 @@ authRoutes.post('/local', async (req, res, next) => {
return res.status(200).json(user?.filter() ?? {});
} catch (e) {
logger.error(e.message, { label: 'Auth' });
logger.error('Something went wrong when trying to authenticate', {
label: 'Auth',
error: e.message,
});
return next({
status: 500,
message: 'Something went wrong.',

Loading…
Cancel
Save