diff --git a/lib/views/admin/theme.js b/lib/views/admin/theme.js index 93c9a2c2..d4651e49 100644 --- a/lib/views/admin/theme.js +++ b/lib/views/admin/theme.js @@ -7,20 +7,40 @@ const extend = require('xtend') module.exports = function (req, res) { if (req.method === 'POST') { - if (req.body.showModuleInteractions) { + if (req.body.showModuleInteractions && + (req.body.showModuleInteractions === 'on' || req.body.showModuleInteractions === 'true')) { config.set('showModuleInteractions', true) - } else { + } else if (req.body.showModuleInteractions && + (req.body.showModuleInteractions === 'off' || req.body.showModuleInteractions === 'false')) { + config.set('showModuleInteractions', false) + } else if (req.body.showModuleInteractions === undefined) { config.set('showModuleInteractions', false) + } else { + config.set('showModuleInteractions', true) // default state } - if (req.body.removePublicEnabled) { + + if (req.body.removePublicEnabled && + (req.body.removePublicEnabled === 'on' || req.body.removePublicEnabled === 'true')) { config.set('removePublicEnabled', true) - } else { + } else if (req.body.removePublicEnabled && + (req.body.removePublicEnabled === 'off' || req.body.removePublicEnabled === 'false')) { + config.set('removePublicEnabled', false) + } else if (req.body.removePublicEnabled === undefined) { config.set('removePublicEnabled', false) + } else { + config.set('removePublicEnabled', true) // default state } - if (req.body.requireLogin) { + + if (req.body.requireLogin && + (req.body.requireLogin === 'on' || req.body.requireLogin === 'true')) { config.set('requireLogin', true) - } else { + } else if (req.body.requireLogin && + (req.body.requireLogin === 'off' || req.body.requireLogin === 'false')) { config.set('requireLogin', false) + } else if (req.body.requireLogin === undefined) { + config.set('requireLogin', false) + } else { + config.set('requireLogin', false) // default state } post(req, res) } else { @@ -47,6 +67,9 @@ function form (req, res) { frontPageText: config.get('frontPageText'), firstLaunch: config.get('firstLaunch'), altHome: config.get('altHome'), + showModuleInteractions: config.get('showModuleInteractions'), + removePublicEnabled: config.get('removePublicEnabled'), + requireLogin: config.get('requireLogin'), currentTheme: currentTheme, themeParameters: themeParameters }