diff --git a/routes/index.js b/routes/index.js index 9f6d1d2..456faf2 100644 --- a/routes/index.js +++ b/routes/index.js @@ -6,7 +6,6 @@ const fs = require('fs/promises') module.exports = ({ db, config }) => { async function ensurePfp (username) { const user = await db.get(username) - console.log(user) if (user.pfp) return const { rows } = await db.allDocs({ include_docs: true }) diff --git a/routes/profile/index.js b/routes/profile/index.js index 0f08457..36aff2d 100644 --- a/routes/profile/index.js +++ b/routes/profile/index.js @@ -9,6 +9,7 @@ module.exports = ({ db, ensurePfp }) => { await ensurePfp(req.user._id) res.render('profile', { title: `Profile Settings - ${req.user._id}` }) }) + router.post('/pfp', verifyAuth(), async (req, res) => { req.user.pfp = req.body.image await db.put(req.user) @@ -16,6 +17,11 @@ module.exports = ({ db, ensurePfp }) => { req.flash('success', 'Saved profile picture!') 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) => { if (!req.body.oldPassword) { req.flash('error', 'Old Password is required') diff --git a/views/profile-password.pug b/views/profile-password.pug index bc64df4..afdc657 100644 --- a/views/profile-password.pug +++ b/views/profile-password.pug @@ -1,6 +1,7 @@ extends layout.pug block content + a.button(href=`${_CC.config.base}profile`) Back form(method='POST') .field label.label Old Password (Required if changing password)