Merge pull request #418 from mz8i/feature/415-no-password-log

Prevent logging passwords in failed login attempts
This commit is contained in:
mz8i 2019-09-30 12:07:46 +01:00 committed by GitHub
commit 37278fd639
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,6 +2,8 @@
* User data access
*
*/
import { errors } from 'pg-promise';
import db from '../../db';
function createUser(user) {
@ -64,8 +66,12 @@ function authUser(username, password) {
return { error: 'Username or password not recognised' }
}
}).catch(function (err) {
console.error(err);
return { error: 'Username or password not recognised' };
if (err instanceof errors.QueryResultError) {
console.error(`Authentication failed for user ${username}`);
return { error: 'Username or password not recognised' };
}
console.error('Error:', err);
return { error: 'Database error' };
})
}