mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
refactor: dont expost entire res._locals to client side
This commit is contained in:
@@ -353,7 +353,7 @@ app.flags = {};
|
|||||||
|
|
||||||
function registerServiceWorker() {
|
function registerServiceWorker() {
|
||||||
// Do not register for Safari browsers
|
// Do not register for Safari browsers
|
||||||
if (!ajaxify.data._locals.useragent.isSafari && 'serviceWorker' in navigator) {
|
if (!config.useragent.isSafari && 'serviceWorker' in navigator) {
|
||||||
navigator.serviceWorker.register(config.relative_path + '/service-worker.js', { scope: config.relative_path + '/' })
|
navigator.serviceWorker.register(config.relative_path + '/service-worker.js', { scope: config.relative_path + '/' })
|
||||||
.then(function () {
|
.then(function () {
|
||||||
console.info('ServiceWorker registration succeeded.');
|
console.info('ServiceWorker registration succeeded.');
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ apiController.loadConfig = async function (req) {
|
|||||||
},
|
},
|
||||||
iconBackgrounds: await user.getIconBackgrounds(req.uid),
|
iconBackgrounds: await user.getIconBackgrounds(req.uid),
|
||||||
emailPrompt: meta.config.emailPrompt,
|
emailPrompt: meta.config.emailPrompt,
|
||||||
|
useragent: req.useragent,
|
||||||
};
|
};
|
||||||
|
|
||||||
let settings = config;
|
let settings = config;
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ module.exports = function (middleware) {
|
|||||||
req.app.set('json spaces', global.env === 'development' || req.query.pretty ? 4 : 0);
|
req.app.set('json spaces', global.env === 'development' || req.query.pretty ? 4 : 0);
|
||||||
return res.json(options);
|
return res.json(options);
|
||||||
}
|
}
|
||||||
|
const optionsString = JSON.stringify(options).replace(/<\//g, '<\\/');
|
||||||
const results = await utils.promiseParallel({
|
const results = await utils.promiseParallel({
|
||||||
header: renderHeaderFooter('renderHeader', req, res, options),
|
header: renderHeaderFooter('renderHeader', req, res, options),
|
||||||
content: renderContent(render, templateToRender, req, res, options),
|
content: renderContent(render, templateToRender, req, res, options),
|
||||||
@@ -76,7 +76,7 @@ module.exports = function (middleware) {
|
|||||||
(res.locals.postHeader || '') +
|
(res.locals.postHeader || '') +
|
||||||
results.content
|
results.content
|
||||||
}<script id="ajaxify-data" type="application/json">${
|
}<script id="ajaxify-data" type="application/json">${
|
||||||
JSON.stringify(options).replace(/<\//g, '<\\/')
|
optionsString
|
||||||
}</script>${
|
}</script>${
|
||||||
res.locals.preFooter || ''
|
res.locals.preFooter || ''
|
||||||
}${results.footer}`;
|
}${results.footer}`;
|
||||||
|
|||||||
Reference in New Issue
Block a user