-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsample-users-data.js
More file actions
63 lines (50 loc) · 1.14 KB
/
sample-users-data.js
File metadata and controls
63 lines (50 loc) · 1.14 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
'use strict';
function getUsers(){
var accounts = [
{
name: 'john',
email: 'john.doe@ibm.com',
password: 'john1',
// menus: [],
},
{
name: 'jane',
email: 'jane.doe@ibm.com',
password: 'jane1',
// menus: [],
},
{
name: 'admin',
email: 'admin@ibm.com',
password: 'admin',
// menus: [],
}
];
return accounts;
};
function createUsers(cb){
// console.log(users);
database.automigrate('UserModel', function(err){
if (err) return cb(err);
User.create(getUsers(), cb);
});
};
function assignAdmin(admin){
database.automigrate('Role', function(err){
if (err) return cb(err);
Role.create({ name:'admin' })
.then(function(role){
role.principals.create({
principalType: RoleMapping.USER,
principalId: admin.id
}, function(err, principal){
console.log('Principal', principal);
});
})
.catch(function(err){
throw err;
});
});
};
module.exports.createUsers = createUsers;
module.exports.assignAdmin = assignAdmin;