Guest User

Untitled

a guest
Sep 2nd, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. Db.prototype.addUser = function(username, password, callback) {
  2. // Use node md5 generator
  3. var md5 = crypto.createHash('md5');
  4. // Generate keys used for authentication
  5. md5.update(username + ":mongo:" + password);
  6. var userPassword = md5.digest('hex');
  7. // Fetch a user collection
  8. this.collection(DbCommand.SYSTEM_USER_COLLECTION, function(err, collection) {
  9. // Insert the user into the system users collections
  10. collection.insert({user: username, pwd: userPassword}, {safe:true}, function(err, documents) {
  11. callback(err, documents);
  12. });
  13. });
  14. };
Add Comment
Please, Sign In to add comment