-
-
Save kmhrussell17/614998b6a5caff418bbcc7bf2be92d44 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const bcrypt = require('bcrypt'); | |
const crypto = require('crypto'); | |
function createNewUser(db, data){ | |
let user = db.createUser({ | |
name: data.name, | |
email: data.email, | |
password: makeHash(data.password), | |
}); | |
if(user) return sanitizeUserData(user); | |
return false; | |
} | |
function makeHash(key, salt_length = 10){ | |
return bcrypt.genSalt(salt_length, function(err, salt) { | |
return bcrypt.hash(key, salt, function(err, hash) { | |
return hash; | |
}); | |
}); | |
} | |
function sanitizeUserData(user) { | |
return user; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment