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:
parent
a031ab0b9b
commit
92b9d60c00
12 changed files with 144 additions and 4 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue