oops accidentally broke password changes

This commit is contained in:
Wingy 2021-09-15 02:55:39 -04:00
parent 9c6c7df92b
commit 62d5e395fa
3 changed files with 7 additions and 1 deletions

View file

@ -6,7 +6,6 @@ const fs = require('fs/promises')
module.exports = ({ db, config }) => { module.exports = ({ db, config }) => {
async function ensurePfp (username) { async function ensurePfp (username) {
const user = await db.get(username) const user = await db.get(username)
console.log(user)
if (user.pfp) return if (user.pfp) return
const { rows } = await db.allDocs({ include_docs: true }) const { rows } = await db.allDocs({ include_docs: true })

View file

@ -9,6 +9,7 @@ module.exports = ({ db, ensurePfp }) => {
await ensurePfp(req.user._id) await ensurePfp(req.user._id)
res.render('profile', { title: `Profile Settings - ${req.user._id}` }) res.render('profile', { title: `Profile Settings - ${req.user._id}` })
}) })
router.post('/pfp', verifyAuth(), async (req, res) => { router.post('/pfp', verifyAuth(), async (req, res) => {
req.user.pfp = req.body.image req.user.pfp = req.body.image
await db.put(req.user) await db.put(req.user)
@ -16,6 +17,11 @@ module.exports = ({ db, ensurePfp }) => {
req.flash('success', 'Saved profile picture!') req.flash('success', 'Saved profile picture!')
res.redirect(`${_CC.config.base}profile`) res.redirect(`${_CC.config.base}profile`)
}) })
router.get('/password', verifyAuth(), async (req, res) => {
await ensurePfp(req.user._id)
res.render('profile-password', { title: `Profile Settings - Password - ${req.user._id}` })
})
router.post('/password', verifyAuth(), (req, res) => { router.post('/password', verifyAuth(), (req, res) => {
if (!req.body.oldPassword) { if (!req.body.oldPassword) {
req.flash('error', 'Old Password is required') req.flash('error', 'Old Password is required')

View file

@ -1,6 +1,7 @@
extends layout.pug extends layout.pug
block content block content
a.button(href=`${_CC.config.base}profile`) Back
form(method='POST') form(method='POST')
.field .field
label.label Old Password (Required if changing password) label.label Old Password (Required if changing password)