-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgen_users.js
46 lines (42 loc) · 1.82 KB
/
gen_users.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
var log = require('./libs/log')(module);
var mongoose = require('./libs/mongoose').mongoose;
var UserModel = require('./libs/mongoose').UserModel;
var ClientModel = require('./libs/mongoose').ClientModel;
var AccessTokenModel = require('./libs/mongoose').AccessTokenModel;
var RefreshTokenModel = require('./libs/mongoose').RefreshTokenModel;
var faker = require('Faker');
UserModel.remove({}, function(err) {
var user = new UserModel({ username: "bob", password: "simplepassword" });
user.save(function(err, user) {
if(err) return log.error(err);
else log.info("New user - %s:%s",user.username,user.password);
});
for(i=0; i<4; i++) {
var user = new UserModel({ username: faker.name.firstName().toLowerCase(), password: faker.lorem.words(1)[0] });
user.save(function(err, user) {
if(err) return log.error(err);
else log.info("New user - %s:%s",user.username,user.password);
});
}
});
ClientModel.remove({}, function(err) {
var client = new ClientModel({ name: "Android Client V1", clientId: "AndroidV1", clientSecret:"abc123" });
client.save(function(err, client) {
if(err) return log.error(err);
else log.info("New client - %s:%s",client.clientId,client.clientSecret);
});
var client = new ClientModel({ name: "Web Client V1", clientId: "WebV1", clientSecret:"abc123" });
client.save(function(err, client) {
if(err) return log.error(err);
else log.info("New client - %s:%s",client.clientId,client.clientSecret);
});
});
AccessTokenModel.remove({}, function (err) {
if (err) return log.error(err);
});
RefreshTokenModel.remove({}, function (err) {
if (err) return log.error(err);
});
setTimeout(function() {
mongoose.disconnect();
}, 3000);