2017-07-08 13:48:34 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const passport = require('./passport');
|
2017-07-08 18:32:04 +00:00
|
|
|
const config = require('config');
|
2017-07-08 13:48:34 +00:00
|
|
|
|
2017-07-09 13:41:53 +00:00
|
|
|
function _getConfig(context) {
|
2017-07-08 13:48:34 +00:00
|
|
|
return {
|
|
|
|
authMethod: passport.authMethod,
|
2017-07-08 18:32:04 +00:00
|
|
|
isAuthMethodLocal: passport.isAuthMethodLocal,
|
2017-07-09 13:41:53 +00:00
|
|
|
externalPasswordResetLink: config.ldap.passwordresetlink,
|
|
|
|
language: config.language || 'en',
|
|
|
|
userId: context.user ? context.user.id : undefined
|
2017-07-08 13:48:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-09 21:16:47 +00:00
|
|
|
function registerRootRoute(router, entryPoint, title) {
|
2017-07-08 13:48:34 +00:00
|
|
|
router.get('/*', passport.csrfProtection, (req, res) => {
|
|
|
|
res.render('react-root', {
|
|
|
|
title,
|
|
|
|
reactEntryPoint: entryPoint,
|
|
|
|
reactCsrfToken: req.csrfToken(),
|
2017-07-09 13:41:53 +00:00
|
|
|
mailtrainConfig: JSON.stringify(_getConfig(req.context))
|
2017-07-08 13:48:34 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
registerRootRoute
|
|
|
|
};
|
|
|
|
|