-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.js
27 lines (26 loc) · 910 Bytes
/
setup.js
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 settings = require('./settings'),
util = require('util'),
mkpass = require('./lib/genji/lib/genji/web/auth').makePassword,
mongo = require('./lib/node-mongodb-native/lib/mongodb');
mongo.connect(settings.db, function(err, db) {
db.open(function(err, db) {
db.collection('users', function(err, users) {
users.count({
username: 'admin'
}, function(err, num) {
if (num == 0) {
users.insert({
username: 'admin',
password: mkpass('1')
}, function(err, doc) {
util.debug(util.inspect(doc));
db.close();
});
} else {
util.puts("user 'admin' already exists");
db.close();
}
});
});
});
});