You can now specifiy PFP=false to disable pfps.
This commit is contained in:
parent
cf1054b888
commit
7fb1e11750
6 changed files with 47 additions and 36 deletions
|
@ -89,6 +89,8 @@ TRUST_PROXY=loopback
|
||||||
BULMASWATCH=default
|
BULMASWATCH=default
|
||||||
# Set to false to disable update notices
|
# Set to false to disable update notices
|
||||||
UPDATE_CHECK=true
|
UPDATE_CHECK=true
|
||||||
|
# Set to false to disable the profile pictures feature
|
||||||
|
PFP=true
|
||||||
|
|
||||||
## Wishlist Settings
|
## Wishlist Settings
|
||||||
# Set to true to not allow users to have their own lists. You may want this for a birthday or wedding.
|
# Set to true to not allow users to have their own lists. You may want this for a birthday or wedding.
|
||||||
|
|
|
@ -13,5 +13,6 @@ module.exports = {
|
||||||
wishlist: require('./wishlist'),
|
wishlist: require('./wishlist'),
|
||||||
base: (process.env.ROOT_PATH || '/').endsWith('/') ? (process.env.ROOT_PATH || '/') : `${process.env.ROOT_PATH}/`,
|
base: (process.env.ROOT_PATH || '/').endsWith('/') ? (process.env.ROOT_PATH || '/') : `${process.env.ROOT_PATH}/`,
|
||||||
trustProxy: process.env.TRUST_PROXY === 'true' ? true : process.env.TRUST_PROXY || 'loopback',
|
trustProxy: process.env.TRUST_PROXY === 'true' ? true : process.env.TRUST_PROXY || 'loopback',
|
||||||
bulmaswatch: (process.env.BULMASWATCH || 'default').toLowerCase()
|
bulmaswatch: (process.env.BULMASWATCH || 'default').toLowerCase(),
|
||||||
|
pfp: process.env.PFP !== 'false'
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ const fs = require('fs/promises')
|
||||||
|
|
||||||
module.exports = ({ db, config }) => {
|
module.exports = ({ db, config }) => {
|
||||||
async function ensurePfp (username) {
|
async function ensurePfp (username) {
|
||||||
|
if (!config.pfp) return
|
||||||
const user = await db.get(username)
|
const user = await db.get(username)
|
||||||
if (user.pfp) return
|
if (user.pfp) return
|
||||||
|
|
||||||
|
@ -56,7 +57,7 @@ module.exports = ({ db, config }) => {
|
||||||
router.use('/wishlist', require('./wishlist')(db))
|
router.use('/wishlist', require('./wishlist')(db))
|
||||||
router.use('/supported-sites', require('./supported-sites')())
|
router.use('/supported-sites', require('./supported-sites')())
|
||||||
|
|
||||||
router.use('/profile', require('./profile')({ db, ensurePfp }))
|
router.use('/profile', require('./profile')({ db, config, ensurePfp }))
|
||||||
|
|
||||||
router.use('/admin-settings', require('./adminSettings')({ db, ensurePfp }))
|
router.use('/admin-settings', require('./adminSettings')({ db, ensurePfp }))
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ const verifyAuth = require('../../middlewares/verifyAuth')
|
||||||
const bcrypt = require('bcrypt-nodejs')
|
const bcrypt = require('bcrypt-nodejs')
|
||||||
const express = require('express')
|
const express = require('express')
|
||||||
|
|
||||||
module.exports = ({ db, ensurePfp }) => {
|
module.exports = ({ db, config, ensurePfp }) => {
|
||||||
const router = express.Router()
|
const router = express.Router()
|
||||||
|
|
||||||
router.get('/', verifyAuth(), async (req, res) => {
|
router.get('/', verifyAuth(), async (req, res) => {
|
||||||
|
@ -11,10 +11,14 @@ module.exports = ({ db, ensurePfp }) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
router.post('/pfp', verifyAuth(), async (req, res) => {
|
router.post('/pfp', verifyAuth(), async (req, res) => {
|
||||||
|
if (config.pfp) {
|
||||||
req.user.pfp = req.body.image
|
req.user.pfp = req.body.image
|
||||||
await db.put(req.user)
|
await db.put(req.user)
|
||||||
if (!req.user.pfp) await ensurePfp(req.user._id)
|
if (!req.user.pfp) await ensurePfp(req.user._id)
|
||||||
req.flash('success', 'Saved profile picture!')
|
req.flash('success', 'Saved profile picture!')
|
||||||
|
} else {
|
||||||
|
req.flash('error', 'Profile pictures are disabled.')
|
||||||
|
}
|
||||||
res.redirect(`${_CC.config.base}profile`)
|
res.redirect(`${_CC.config.base}profile`)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
extends layout.pug
|
extends layout.pug
|
||||||
|
|
||||||
block content
|
block content
|
||||||
|
if config.pfp
|
||||||
h2 Profile
|
h2 Profile
|
||||||
div(style='margin-top: 1em;')
|
div(style='margin-top: 1em;')
|
||||||
.columns(style='margin-top: 1em;')
|
.columns(style='margin-top: 1em;')
|
||||||
|
|
|
@ -7,6 +7,7 @@ block content
|
||||||
a(href=`${_CC.config.base}wishlist/${req.user._id}`)
|
a(href=`${_CC.config.base}wishlist/${req.user._id}`)
|
||||||
.box
|
.box
|
||||||
.columns
|
.columns
|
||||||
|
if config.pfp
|
||||||
.column.is-1(style='overflow: hidden;')
|
.column.is-1(style='overflow: hidden;')
|
||||||
figure.image.is-square.is-fullwidth.is-marginless(style='display: inline-block;')
|
figure.image.is-square.is-fullwidth.is-marginless(style='display: inline-block;')
|
||||||
img.is-rounded.is-fullwidth(src=req.user.pfp, style='object-fit: cover;')
|
img.is-rounded.is-fullwidth(src=req.user.pfp, style='object-fit: cover;')
|
||||||
|
@ -20,6 +21,7 @@ block content
|
||||||
a(href=`${_CC.config.base}wishlist/${user.id}`)
|
a(href=`${_CC.config.base}wishlist/${user.id}`)
|
||||||
.box
|
.box
|
||||||
.columns
|
.columns
|
||||||
|
if config.pfp
|
||||||
.column.is-1(style='overflow: hidden;')
|
.column.is-1(style='overflow: hidden;')
|
||||||
figure.image.is-square.is-fullwidth.is-marginless(style='display: inline-block;')
|
figure.image.is-square.is-fullwidth.is-marginless(style='display: inline-block;')
|
||||||
img.is-rounded.is-fullwidth(src=user.doc.pfp, style='object-fit: cover;')
|
img.is-rounded.is-fullwidth(src=user.doc.pfp, style='object-fit: cover;')
|
||||||
|
|
Loading…
Reference in a new issue