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) => {
|
||||||
req.user.pfp = req.body.image
|
if (config.pfp) {
|
||||||
await db.put(req.user)
|
req.user.pfp = req.body.image
|
||||||
if (!req.user.pfp) await ensurePfp(req.user._id)
|
await db.put(req.user)
|
||||||
req.flash('success', 'Saved profile picture!')
|
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`)
|
res.redirect(`${_CC.config.base}profile`)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,29 +1,30 @@
|
||||||
extends layout.pug
|
extends layout.pug
|
||||||
|
|
||||||
block content
|
block content
|
||||||
h2 Profile
|
if config.pfp
|
||||||
div(style='margin-top: 1em;')
|
h2 Profile
|
||||||
.columns(style='margin-top: 1em;')
|
div(style='margin-top: 1em;')
|
||||||
.column.is-narrow
|
.columns(style='margin-top: 1em;')
|
||||||
.box
|
.column.is-narrow
|
||||||
.columns
|
.box
|
||||||
.column
|
.columns
|
||||||
figure.image.is-square(style='display: inline-block; width: 90%;')
|
.column
|
||||||
img.is-rounded(src=req.user.pfp, style='object-fit: cover;')
|
figure.image.is-square(style='display: inline-block; width: 90%;')
|
||||||
.column.is-narrow
|
img.is-rounded(src=req.user.pfp, style='object-fit: cover;')
|
||||||
.column
|
.column.is-narrow
|
||||||
span.is-size-3= req.user._id
|
.column
|
||||||
br
|
span.is-size-3= req.user._id
|
||||||
br
|
br
|
||||||
form(action=`${_CC.config.base}profile/pfp`, method='POST')
|
br
|
||||||
label.label Image URL
|
form(action=`${_CC.config.base}profile/pfp`, method='POST')
|
||||||
.field.has-addons
|
label.label Image URL
|
||||||
.control
|
.field.has-addons
|
||||||
input.input(name='image', value=req.user.pfp)
|
.control
|
||||||
.control
|
input.input(name='image', value=req.user.pfp)
|
||||||
button.button.is-primary(type='submit')
|
.control
|
||||||
span.icon
|
button.button.is-primary(type='submit')
|
||||||
i.fas.fa-save
|
span.icon
|
||||||
|
i.fas.fa-save
|
||||||
h2 Security
|
h2 Security
|
||||||
a.button.is-primary(href=`${_CC.config.base}profile/password`)
|
a.button.is-primary(href=`${_CC.config.base}profile/password`)
|
||||||
span.icon
|
span.icon
|
||||||
|
|
|
@ -7,9 +7,10 @@ block content
|
||||||
a(href=`${_CC.config.base}wishlist/${req.user._id}`)
|
a(href=`${_CC.config.base}wishlist/${req.user._id}`)
|
||||||
.box
|
.box
|
||||||
.columns
|
.columns
|
||||||
.column.is-1(style='overflow: hidden;')
|
if config.pfp
|
||||||
figure.image.is-square.is-fullwidth.is-marginless(style='display: inline-block;')
|
.column.is-1(style='overflow: hidden;')
|
||||||
img.is-rounded.is-fullwidth(src=req.user.pfp, style='object-fit: cover;')
|
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
|
.column
|
||||||
span=req.user._id
|
span=req.user._id
|
||||||
span : ???/???
|
span : ???/???
|
||||||
|
@ -20,9 +21,10 @@ block content
|
||||||
a(href=`${_CC.config.base}wishlist/${user.id}`)
|
a(href=`${_CC.config.base}wishlist/${user.id}`)
|
||||||
.box
|
.box
|
||||||
.columns
|
.columns
|
||||||
.column.is-1(style='overflow: hidden;')
|
if config.pfp
|
||||||
figure.image.is-square.is-fullwidth.is-marginless(style='display: inline-block;')
|
.column.is-1(style='overflow: hidden;')
|
||||||
img.is-rounded.is-fullwidth(src=user.doc.pfp, style='object-fit: cover;')
|
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
|
.column
|
||||||
span= user.id
|
span= user.id
|
||||||
span : #{totals(user.doc.wishlist).pledged}/#{user.doc.wishlist.length}
|
span : #{totals(user.doc.wishlist).pledged}/#{user.doc.wishlist.length}
|
||||||
|
|
Loading…
Reference in a new issue