From 5295e413be9d661e39b020521ff025f17933a13f Mon Sep 17 00:00:00 2001 From: NGPixel Date: Wed, 9 Sep 2020 19:35:43 -0400 Subject: [PATCH] fix: bypass page rule check for global permission check + handle missing page extra field --- server/controllers/common.js | 3 +++ server/core/auth.js | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/server/controllers/common.js b/server/controllers/common.js index c6940204..bf67b519 100644 --- a/server/controllers/common.js +++ b/server/controllers/common.js @@ -148,6 +148,9 @@ router.get(['/e', '/e/*'], async (req, res, next) => { await page.$relatedQuery('tags') page.tags = _.map(page.tags, 'tag') + // Handle missing extra field + page.extra = page.extra || { css: '', js: '' } + // -> Beautify Script CSS if (!_.isEmpty(page.extra.css)) { page.extra.css = new CleanCSS({ format: 'beautify' }).minify(page.extra.css).styles diff --git a/server/core/auth.js b/server/core/auth.js index ae5df07b..56e4ab2c 100644 --- a/server/core/auth.js +++ b/server/core/auth.js @@ -226,8 +226,13 @@ module.exports = { return false } + // Skip if no page rule to check + if (!page) { + return true + } + // Check Page Rules - if (page && user.groups) { + if (user.groups) { let checkState = { deny: false, match: false,