From ad02bc3714b5833dd9d2dd2e71a5e90db8255bd2 Mon Sep 17 00:00:00 2001 From: Wingy Date: Mon, 3 Oct 2022 10:49:36 -0400 Subject: [PATCH] add _CCUNKNOWN --- middlewares/publicRoute.js | 2 +- middlewares/verifyAuth.js | 7 ++++++- views/includes/navbar.pug | 2 +- views/wishlists.pug | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/middlewares/publicRoute.js b/middlewares/publicRoute.js index 59b8943..498d449 100644 --- a/middlewares/publicRoute.js +++ b/middlewares/publicRoute.js @@ -2,7 +2,7 @@ const verifyAuth = require('./verifyAuth') const publicMiddleware = () => global._CC.config.wishlist.public ? (req, res, next) => { - if (!req.user) req.user = { _id: 'Unknown' } + if (!req.user) req.user = { _id: '_CCUNKNOWN' } next() } : verifyAuth() diff --git a/middlewares/verifyAuth.js b/middlewares/verifyAuth.js index bccd43e..aa823f3 100644 --- a/middlewares/verifyAuth.js +++ b/middlewares/verifyAuth.js @@ -9,7 +9,12 @@ module.exports = options => { return res.send('auth fail') } if (authed) return next() - if (_CC.config.guestPassword && req.query.pw === _CC.config.guestPassword) return next() + if (_CC.config.guestPassword && req.query.pw === _CC.config.guestPassword) { + req.user = { + _id: '_CCUNKNOWN' + } + return next() + } res.redirect(options.failureRedirect || config.defaultFailureRedirect) } } diff --git a/views/includes/navbar.pug b/views/includes/navbar.pug index 1a9f262..af148d5 100644 --- a/views/includes/navbar.pug +++ b/views/includes/navbar.pug @@ -21,7 +21,7 @@ nav.navbar.is-fixed-top(role='navigation', aria-label='main navigation',style='b .navbar-menu#navBarMenu .navbar-start if req.isAuthenticated() - if req.user._id === 'Unknown' + if req.user._id === '_CCUNKNOWN' .navbar-item a.button.is-primary(href='/login')= lang('NAVBAR_LOGIN') else diff --git a/views/wishlists.pug b/views/wishlists.pug index de246b6..87adb6f 100644 --- a/views/wishlists.pug +++ b/views/wishlists.pug @@ -2,7 +2,7 @@ extends layout.pug block content ul.noStyle.noLeftMargin - if req.user._id !== 'Unknown' + if req.user._id !== '_CCUNKNOWN' li a(href=`${_CC.config.base}wishlist/${req.user._id}`) .box