add _CCUNKNOWN

This commit is contained in:
Wingy 2022-10-03 10:49:36 -04:00
parent 1b8d474756
commit ad02bc3714
4 changed files with 9 additions and 4 deletions

View file

@ -2,7 +2,7 @@ const verifyAuth = require('./verifyAuth')
const publicMiddleware = () => global._CC.config.wishlist.public const publicMiddleware = () => global._CC.config.wishlist.public
? (req, res, next) => { ? (req, res, next) => {
if (!req.user) req.user = { _id: 'Unknown' } if (!req.user) req.user = { _id: '_CCUNKNOWN' }
next() next()
} }
: verifyAuth() : verifyAuth()

View file

@ -9,7 +9,12 @@ module.exports = options => {
return res.send('auth fail') return res.send('auth fail')
} }
if (authed) return next() 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) res.redirect(options.failureRedirect || config.defaultFailureRedirect)
} }
} }

View file

@ -21,7 +21,7 @@ nav.navbar.is-fixed-top(role='navigation', aria-label='main navigation',style='b
.navbar-menu#navBarMenu .navbar-menu#navBarMenu
.navbar-start .navbar-start
if req.isAuthenticated() if req.isAuthenticated()
if req.user._id === 'Unknown' if req.user._id === '_CCUNKNOWN'
.navbar-item .navbar-item
a.button.is-primary(href='/login')= lang('NAVBAR_LOGIN') a.button.is-primary(href='/login')= lang('NAVBAR_LOGIN')
else else

View file

@ -2,7 +2,7 @@ extends layout.pug
block content block content
ul.noStyle.noLeftMargin ul.noStyle.noLeftMargin
if req.user._id !== 'Unknown' if req.user._id !== '_CCUNKNOWN'
li li
a(href=`${_CC.config.base}wishlist/${req.user._id}`) a(href=`${_CC.config.base}wishlist/${req.user._id}`)
.box .box