-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
103 lines (101 loc) · 3.02 KB
/
index.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
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
'use strict';
var appenvironment,
extend = require('utils-merge'),
path = require('path'),
fs = require('fs-extra'),
loginExtSettingsFile = path.join(process.cwd(), 'content/config/extensions/periodicjs.ext.login/settings.json'),
loginSettingJSON,
default_new_user_settings = {
settings: {
usepassword: true,
requireusername: true,
requireemail: true,
disablesocialsignin: true
},
new_user_validation: {
checkusername: true,
checkpassword: true,
length_of_username: 1,
length_of_password: 8,
send_new_user_email: true
},
complexitySettings: {
useComplexity: true,
settings: {
weak: {
uppercase: 1,
lowercase: 1,
min: 8
},
medium: {
uppercase: 1,
lowercase: 1,
digit: 1,
min: 8
},
strong: {
uppercase: 1,
lowercase: 1,
digit: 1,
special: 1,
min: 8
}
}
}
},
settingJSON;
/**
* The install extension, configures an instance of perioidic through a web interface.
* @{@link https://github.com/typesettin/periodicjs.ext.install}
* @author Yaw Joseph Etse
* @copyright Copyright (c) 2014 Typesettin. All rights reserved.
* @license MIT
* @exports periodicjs.ext.install
* @requires module:passport
* @param {object} periodic variable injection of resources from current periodic instance
*/
module.exports = function (periodic) {
// express,app,logger,config,db,mongoose
appenvironment = periodic.settings.application.environment;
try {
settingJSON = fs.readJsonSync(loginExtSettingsFile);
}
catch (e) {
settingJSON = {};
}
loginSettingJSON = (settingJSON[appenvironment]) ? extend(default_new_user_settings, settingJSON[appenvironment]) : default_new_user_settings;
periodic.app.controller.extension.install = {
loginExtSettings: loginSettingJSON
};
if(!periodic.core){
var
Utilities = require('periodicjs.core.utilities'),
Controllers = require('periodicjs.core.controller');
require(path.join(__dirname,'../../content/config/model'))({
mongoose: periodic.db.mongoose,
dburl: periodic.db.url,
dboptions: periodic.db.mongooptions,
debug: periodic.settings.debug,
periodic: periodic
});
periodic.core = {
controller: new Controllers(periodic),
utilities: new Utilities(periodic)
};
}
periodic.app.controller.extension.install = {
install: require('./controller/install')(periodic)
};
var installRouter = periodic.express.Router(),
installController = periodic.app.controller.extension.install.install,
homeController = require(path.join(process.cwd(), 'app/controller/home'))(periodic);
installRouter.get('*', global.CoreCache.disableCache);
installRouter.get('/', installController.index);
installRouter.get('/install', installController.index);
// installRouter.get('/install/getlog', installController.get_outputlog);
installRouter.post('/install/updateconfig', installController.checkUserValidation, installController.update);
installRouter.get('/*', installController.index);
installRouter.use('*', homeController.catch404);
periodic.app.use(installRouter);
return periodic;
};