Custom forms list and CUD.
This commit is contained in:
parent
f6e1938ff9
commit
361af18384
12 changed files with 1068 additions and 209 deletions
|
@ -3,8 +3,9 @@
|
|||
const passport = require('./passport');
|
||||
const config = require('config');
|
||||
const permissions = require('./permissions');
|
||||
const forms = require('../models/forms');
|
||||
|
||||
function getAnonymousConfig(context) {
|
||||
async function getAnonymousConfig(context) {
|
||||
return {
|
||||
authMethod: passport.authMethod,
|
||||
isAuthMethodLocal: passport.isAuthMethodLocal,
|
||||
|
@ -14,17 +15,18 @@ function getAnonymousConfig(context) {
|
|||
}
|
||||
}
|
||||
|
||||
function getAuthenticatedConfig(context) {
|
||||
async function getAuthenticatedConfig(context) {
|
||||
return {
|
||||
defaultCustomFormValues: await forms.getDefaultCustomFormValues(),
|
||||
userId: context.user.id
|
||||
}
|
||||
}
|
||||
|
||||
function registerRootRoute(router, entryPoint, title) {
|
||||
router.get('/*', passport.csrfProtection, (req, res) => {
|
||||
const mailtrainConfig = getAnonymousConfig(req.context);
|
||||
router.getAsync('/*', passport.csrfProtection, async (req, res) => {
|
||||
const mailtrainConfig = await getAnonymousConfig(req.context);
|
||||
if (req.user) {
|
||||
Object.assign(mailtrainConfig, getAuthenticatedConfig(req.context));
|
||||
Object.assign(mailtrainConfig, await getAuthenticatedConfig(req.context));
|
||||
}
|
||||
|
||||
res.render('react-root', {
|
||||
|
@ -37,7 +39,7 @@ function registerRootRoute(router, entryPoint, title) {
|
|||
}
|
||||
|
||||
module.exports = {
|
||||
registerRootRoute,
|
||||
registerRootRoute,
|
||||
getAuthenticatedConfig
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue