Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Db.prototype.addUser = function(username, password, callback) {
- // Use node md5 generator
- var md5 = crypto.createHash('md5');
- // Generate keys used for authentication
- md5.update(username + ":mongo:" + password);
- var userPassword = md5.digest('hex');
- // Fetch a user collection
- this.collection(DbCommand.SYSTEM_USER_COLLECTION, function(err, collection) {
- // Insert the user into the system users collections
- collection.insert({user: username, pwd: userPassword}, {safe:true}, function(err, documents) {
- callback(err, documents);
- });
- });
- };
Add Comment
Please, Sign In to add comment