-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmelody.js
More file actions
27 lines (22 loc) · 741 Bytes
/
melody.js
File metadata and controls
27 lines (22 loc) · 741 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
var config = require('./config');
var crypto = require('crypto');
var melody = require('./lib/melody');
melody.start(function(err) {
var Person = melody.resources.Person;
var usernames = Object.keys(config.users);
usernames.forEach(function(username) {
Person.get({
username: username
}, function(err, person) {
if (err || person) return;
var user = config.users[username];
var password = crypto.randomBytes(12).toString('base64');
user.username = username;
user.password = password;
Person.create(user, function(err, person) {
if (err) return console.error(err);
console.log('Created user "'+person.username+'", password:', password);
});
});
});
});