add password hashing function + easier prod

This commit is contained in:
2023-07-16 14:59:07 +02:00
parent 8b6c190e15
commit e5d3e08a75
4 changed files with 20 additions and 7 deletions

View File

@@ -18,10 +18,16 @@
const bcrypt = require( 'bcrypt' );
const db = require( '../backend/db/db.js' );
module.exports.checkpassword = function checkpassword ( username, password ) {
module.exports.checkpassword = ( username, password ) => {
return new Promise( resolve => {
db.getDataSimple( 'admin', 'email', username ).then( data => {
resolve( bcrypt.compareSync( password, data ) );
} );
} );
};
module.exports.hashPassword = ( password ) => {
return new Promise( resolve => {
resolve( bcrypt.hashSync( password, 10 ) );
} );
};

View File

@@ -24,4 +24,10 @@ module.exports.checkpassword = function checkpassword ( email, password ) {
} );
} );
} );
};
module.exports.hashPassword = ( password ) => {
return new Promise( resolve => {
resolve( bcrypt.hashSync( password, 10 ) );
} );
};