lib/db/db.js
/**
 * Inserts a new user in the database with the propper password hashing
 * 
 * @param {string} username
 * @param {string} password - Non hashed password
 * @param {string} email
 * @param {boolean} [isAdmin=false]
 * @returns {Promise<Object>}
 * @throws {Error} - Throws a generic error when a user insertion cant be performed.
 */
Inserts a new user in the database with the propper password hashing


Inserts a new user in the database with the propper password hashing
function AddNewUserToDB(username, password, email, isAdmin = false){
    const hash = bcrypt.hashSync(password, credentials.bcryptConfig.saltRounds);
    return knex('users').insert({username: username, password: hash, email: email, isadmin: isAdmin})
        .then(() => {
            console.log(`New user ${username} created.`);
        });
}
function AddNewUserToDB ( username , password , email , isAdmin = false ) { const hash = bcrypt . hashSync ( password , credentials . bcryptConfig . saltRounds ) ; return knex ( 'users' ) . insert ( { username : username , password : hash , email : email , isadmin : isAdmin } ) . then ( ( ) => { console . log ( ` ${ username } ` ) ; } ) ; }
Inserts a new user in the database with the propper password hashing
Inserts a new user in the database with the propper password hashing