mirror of
https://github.com/kaythomas0/noisedash.git
synced 2025-11-14 20:27:59 +00:00
Add account page
This commit is contained in:
@@ -232,6 +232,33 @@ router.patch('/users/dark-mode', (req, res) => {
|
||||
})
|
||||
})
|
||||
|
||||
router.patch('/users/password', (req, res) => {
|
||||
if (!req.user) {
|
||||
return res.sendStatus(401)
|
||||
}
|
||||
|
||||
const salt = crypto.randomBytes(16)
|
||||
crypto.pbkdf2(req.body.password, salt, 10000, 32, 'sha256', (err, hashedPassword) => {
|
||||
if (err) {
|
||||
logger.error(err)
|
||||
return res.sendStatus(500)
|
||||
}
|
||||
|
||||
db.run('UPDATE users SET hashed_password = ?, salt = ? WHERE id = ?', [
|
||||
hashedPassword,
|
||||
salt,
|
||||
req.user.id
|
||||
], (err) => {
|
||||
if (err) {
|
||||
logger.error(err)
|
||||
return res.sendStatus(500)
|
||||
}
|
||||
|
||||
return res.sendStatus(200)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
router.delete('/users/:userId', (req, res) => {
|
||||
if (!req.user) {
|
||||
return res.sendStatus(401)
|
||||
|
||||
Reference in New Issue
Block a user