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
|
||||
# Set to false to disable update notices
|
||||
UPDATE_CHECK=true
|
||||
# Set to false to disable the profile pictures feature
|
||||
PFP=true
|
||||
|
||||
## Wishlist Settings
|
||||
# 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'),
|
||||
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',
|
||||
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 }) => {
|
||||
async function ensurePfp (username) {
|
||||
if (!config.pfp) return
|
||||
const user = await db.get(username)
|
||||
if (user.pfp) return
|
||||
|
||||
|
@ -56,7 +57,7 @@ module.exports = ({ db, config }) => {
|
|||
router.use('/wishlist', require('./wishlist')(db))
|
||||
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 }))
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ const verifyAuth = require('../../middlewares/verifyAuth')
|
|||
const bcrypt = require('bcrypt-nodejs')
|
||||
const express = require('express')
|
||||
|
||||
module.exports = ({ db, ensurePfp }) => {
|
||||
module.exports = ({ db, config, ensurePfp }) => {
|
||||
const router = express.Router()
|
||||
|
||||
router.get('/', verifyAuth(), async (req, res) => {
|
||||
|
@ -11,10 +11,14 @@ module.exports = ({ db, ensurePfp }) => {
|
|||
})
|
||||
|
||||
router.post('/pfp', verifyAuth(), async (req, res) => {
|
||||
req.user.pfp = req.body.image
|
||||
await db.put(req.user)
|
||||
if (!req.user.pfp) await ensurePfp(req.user._id)
|
||||
req.flash('success', 'Saved profile picture!')
|
||||
if (config.pfp) {
|
||||
req.user.pfp = req.body.image
|
||||
await db.put(req.user)
|
||||
if (!req.user.pfp) await ensurePfp(req.user._id)
|
||||
req.flash('success', 'Saved profile picture!')
|
||||
} else {
|
||||
req.flash('error', 'Profile pictures are disabled.')
|
||||
}
|
||||
res.redirect(`${_CC.config.base}profile`)
|
||||
})
|
||||
|
||||
|
|
|
@ -1,29 +1,30 @@
|
|||
extends layout.pug
|
||||
|
||||
block content
|
||||
h2 Profile
|
||||
div(style='margin-top: 1em;')
|
||||
.columns(style='margin-top: 1em;')
|
||||
.column.is-narrow
|
||||
.box
|
||||
.columns
|
||||
.column
|
||||
figure.image.is-square(style='display: inline-block; width: 90%;')
|
||||
img.is-rounded(src=req.user.pfp, style='object-fit: cover;')
|
||||
.column.is-narrow
|
||||
.column
|
||||
span.is-size-3= req.user._id
|
||||
br
|
||||
br
|
||||
form(action=`${_CC.config.base}profile/pfp`, method='POST')
|
||||
label.label Image URL
|
||||
.field.has-addons
|
||||
.control
|
||||
input.input(name='image', value=req.user.pfp)
|
||||
.control
|
||||
button.button.is-primary(type='submit')
|
||||
span.icon
|
||||
i.fas.fa-save
|
||||
if config.pfp
|
||||
h2 Profile
|
||||
div(style='margin-top: 1em;')
|
||||
.columns(style='margin-top: 1em;')
|
||||
.column.is-narrow
|
||||
.box
|
||||
.columns
|
||||
.column
|
||||
figure.image.is-square(style='display: inline-block; width: 90%;')
|
||||
img.is-rounded(src=req.user.pfp, style='object-fit: cover;')
|
||||
.column.is-narrow
|
||||
.column
|
||||
span.is-size-3= req.user._id
|
||||
br
|
||||
br
|
||||
form(action=`${_CC.config.base}profile/pfp`, method='POST')
|
||||
label.label Image URL
|
||||
.field.has-addons
|
||||
.control
|
||||
input.input(name='image', value=req.user.pfp)
|
||||
.control
|
||||
button.button.is-primary(type='submit')
|
||||
span.icon
|
||||
i.fas.fa-save
|
||||
h2 Security
|
||||
a.button.is-primary(href=`${_CC.config.base}profile/password`)
|
||||
span.icon
|
||||
|
|
|
@ -7,9 +7,10 @@ block content
|
|||
a(href=`${_CC.config.base}wishlist/${req.user._id}`)
|
||||
.box
|
||||
.columns
|
||||
.column.is-1(style='overflow: hidden;')
|
||||
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;')
|
||||
if config.pfp
|
||||
.column.is-1(style='overflow: hidden;')
|
||||
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;')
|
||||
.column
|
||||
span=req.user._id
|
||||
span : ???/???
|
||||
|
@ -20,9 +21,10 @@ block content
|
|||
a(href=`${_CC.config.base}wishlist/${user.id}`)
|
||||
.box
|
||||
.columns
|
||||
.column.is-1(style='overflow: hidden;')
|
||||
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;')
|
||||
if config.pfp
|
||||
.column.is-1(style='overflow: hidden;')
|
||||
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;')
|
||||
.column
|
||||
span= user.id
|
||||
span : #{totals(user.doc.wishlist).pledged}/#{user.doc.wishlist.length}
|
||||
|
|
Loading…
Reference in a new issue