Revert "Old partial attempt at "public mode""

This reverts commit 8f6b030ca8.
This commit is contained in:
Wingy 2020-10-29 11:25:05 -04:00
parent 8f6b030ca8
commit 066d72b153
6 changed files with 18 additions and 37 deletions

View file

@ -1,11 +0,0 @@
const verifyAuth = require('./verifyAuth')
const middlewareNoop = ( (_1, _2, next) => next() )
const publicMiddleware = () => process.env.LISTS_PUBLIC === 'true' ?
(req, res, next) => {
if (!req.user) req.user = { _id: 'Unknown' }
next()
}
: verifyAuth()
module.exports = publicMiddleware

View file

@ -1,5 +1,4 @@
const verifyAuth = require('../middlewares/verifyAuth');
const public = require('../middlewares/public');
const express = require('express');
const path = require('path');
@ -17,7 +16,7 @@ module.exports = ({ db, config }) => {
next();
}
},
public(),
verifyAuth(),
(req, res) => {
res.redirect('/wishlist');
}

View file

@ -1,5 +1,4 @@
const verifyAuth = require('../../middlewares/verifyAuth');
const public = require('../../middlewares/public');
const getProductName = require('get-product-name');
const express = require('express');
const config = require('../../config');
@ -30,7 +29,7 @@ const ValidURL = (string) => { // Ty SO
module.exports = (db) => {
const router = express.Router();
router.get('/', public(), async (req, res) => {
router.get('/', verifyAuth(), async (req, res) => {
const docs = await db.allDocs({ include_docs: true })
if (process.env.SINGLE_LIST === 'true') {
for (row of docs.rows) {
@ -40,7 +39,7 @@ module.exports = (db) => {
res.render('wishlists', { title: 'Wishlists', users: docs.rows, totals})
});
router.get('/:user', public(), async (req, res) => {
router.get('/:user', verifyAuth(), async (req, res) => {
try {
const dbUser = await db.get(req.params.user);
if (process.env.SINGLE_LIST === 'true') {

View file

@ -23,17 +23,13 @@ nav.navbar.is-fixed-top(role='navigation', aria-label='main navigation',style='b
.navbar-item.has-dropdown.is-hoverable
a.navbar-link= req.user._id
.navbar-dropdown
if req.user._id === 'Unknown'
.navbar-item
a.button.is-primary(href='/login') Log In
else
+navBarLink(`/wishlist/${req.user._id}`, 'My Wishlist')
+navBarLink('/profile', 'Profile')
if req.user.admin
+navBarLink('/admin-settings', 'Admin settings')
hr.navbar-divider
.navbar-item
form#logoutForm(action='/logout', method='POST')
button.button.is-warning(type='submit') Log Out
+navBarLink(`/wishlist/${req.user._id}`, 'My Wishlist')
+navBarLink('/profile', 'Profile')
if req.user.admin
+navBarLink('/admin-settings', 'Admin settings')
hr.navbar-divider
.navbar-item
form#logoutForm(action='/logout', method='POST')
button.button.is-warning(type='submit') Log Out
//-+navBarLink('javascript:document.getElementById("logoutForm").submit()', 'Log Out')
script(src="/js/nav.js")

View file

@ -12,8 +12,7 @@ block title
span #{config.siteTitle} - #{title}
block content
if req.user
script(type='data/user_id')= req.user._id
script(type='data/user_id')= req.user._id
if process.env.TABLE !== 'false'
.box
table.table.has-mobile-cards

View file

@ -2,13 +2,12 @@ extends layout.pug
block content
ul.noStyle.noLeftMargin
if req.user._id !== 'Unknown'
li
a(href=`/wishlist/${req.user._id}`)
.box
span=req.user._id
span : ???/???
progress.progress(value=1, max=1)
li
a(href=`/wishlist/${req.user._id}`)
.box
span=req.user._id
span : ???/???
progress.progress(value=1, max=1)
each user in users
if req.user._id !== user.id
li