notify user when accepted, fix #308

This commit is contained in:
lesion 2023-10-25 09:50:20 +02:00
parent 54cc50169b
commit deb2367a44
No known key found for this signature in database
GPG key ID: 352918250B012177
2 changed files with 3 additions and 6 deletions

View file

@ -62,13 +62,9 @@ const userController = {
if (!user) { return res.status(404).json({ success: false, message: 'User not found!' }) }
if (req.body.id !== req.user.id && !req.user.is_admin) {
return res.status(400).json({ succes: false, message: 'Not allowed' })
}
if (!req.body.password) { delete req.body.password }
if (!user.is_active && req.body.is_active && user.recover_code) {
if ((!user.is_active && req.body.is_active) || user.recover_code) {
mail.send(user.email, 'confirm', { user, config }, res.locals.settings.locale)
}
@ -89,6 +85,7 @@ const userController = {
}
req.body.is_active = false
req.body.is_admin = false
// check email
if (!linkify.test(req.body.email, 'email')) {

View file

@ -83,7 +83,7 @@ module.exports = () => {
api.post('/user', isAdmin, userController.create)
// update user
api.put('/user', isAuth, userController.update)
api.put('/user', isAdmin, userController.update)
// delete user
api.delete('/user/:id', isAdmin, userController.remove)