-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.js
More file actions
83 lines (80 loc) · 2.69 KB
/
install.js
File metadata and controls
83 lines (80 loc) · 2.69 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
module.exports = {
/**
* Install function run in we.js site install.
*
* @param {Object} we we.js object
* @param {Function} done callback
*/
install: function install(we, done) {
we.log.info('Starting project install...');
we.utils.async.series([
function registerUser1(done) {
var user1 = {
username: 'administrator',
biography: 'The administrator user account!',
email: 'contato@albertosouza.net',
password: '123', // change after install
displayName: 'Administrator',
language: 'en-us',
active: true
};
we.log.info('I will create the user: ', user1);
we.db.models.user.create(user1)
.then(function (user) {
we.log.info('New User with id: ', user.id);
// set the password
user.updatePassword(user1.password , function(error) {
if (error) return done(error);
// add as admin
// check if the role exists
we.db.models.role.find({
where: { name: 'administrator' }
}).then(function (role) {
if (!role) return done('administrator role not found');
user.addRole(role).then(function() {
we.log.info('role ' +role.name+ ' set to user ' + user.username);
return done();
});
});
});
});
},
// function setDefaultRolePermissions(done) {
// var setRolePermissions = require('./bin/install/4_setRolePermissions.js');
// setRolePermissions(we, done);
// },
function createDefaultMenus(done) {
we.utils.async.series([
function createMainMenu(done) {
we.db.models.menu.create({
name: 'main',
class: 'nav navbar-nav collapse navbar-collapse '
}).then(function (r){
we.log.info('New menu with name: '+r.name+' and id: '+r.id);
// then create menu links
we.db.models.link.bulkCreate([
{
href: '/',
text: 'Home',
title: 'Home page',
menuId: r.id
}
]).then(function(){
done();
}).catch(done);
}).catch(done);
},
function createSocialMenu(done) {
we.db.models.menu.create({
name: 'social',
class: 'list-inline text-center'
}).then(function (r) {
we.log.info('New menu with name: '+r.name+' and id: '+r.id);
done();
}).catch(done);
}
], done);
}
], done);
}
};