1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-06 03:50:26 +02:00

Add ability to delete our account

This commit is contained in:
Chocobozzz 2018-08-08 10:55:27 +02:00
parent a031ab0b9b
commit 92b9d60c00
No known key found for this signature in database
GPG key ID: 583A612D890159BE
12 changed files with 144 additions and 4 deletions

View file

@ -74,6 +74,19 @@ const usersRemoveValidator = [
}
]
const deleteMeValidator = [
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
const user: UserModel = res.locals.oauth.token.User
if (user.username === 'root') {
return res.status(400)
.send({ error: 'You cannot delete your root account.' })
.end()
}
return next()
}
]
const usersUpdateValidator = [
param('id').isInt().not().isEmpty().withMessage('Should have a valid id'),
body('email').optional().isEmail().withMessage('Should have a valid email attribute'),
@ -215,6 +228,7 @@ const usersResetPasswordValidator = [
export {
usersAddValidator,
deleteMeValidator,
usersRegisterValidator,
usersRemoveValidator,
usersUpdateValidator,