mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 18:29:27 +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
|
@ -30,6 +30,7 @@ import {
|
|||
usersVideoRatingValidator
|
||||
} from '../../middlewares'
|
||||
import {
|
||||
deleteMeValidator,
|
||||
usersAskResetPasswordValidator,
|
||||
usersResetPasswordValidator,
|
||||
videoImportsSortValidator,
|
||||
|
@ -62,6 +63,11 @@ usersRouter.get('/me',
|
|||
authenticate,
|
||||
asyncMiddleware(getUserInformation)
|
||||
)
|
||||
usersRouter.delete('/me',
|
||||
authenticate,
|
||||
asyncMiddleware(deleteMeValidator),
|
||||
asyncMiddleware(deleteMe)
|
||||
)
|
||||
|
||||
usersRouter.get('/me/video-quota-used',
|
||||
authenticate,
|
||||
|
@ -296,8 +302,18 @@ async function listUsers (req: express.Request, res: express.Response, next: exp
|
|||
return res.json(getFormattedObjects(resultList.data, resultList.total))
|
||||
}
|
||||
|
||||
async function deleteMe (req: express.Request, res: express.Response) {
|
||||
const user: UserModel = res.locals.oauth.token.User
|
||||
|
||||
await user.destroy()
|
||||
|
||||
auditLogger.delete(res.locals.oauth.token.User.Account.Actor.getIdentifier(), new UserAuditView(user.toFormattedJSON()))
|
||||
|
||||
return res.sendStatus(204)
|
||||
}
|
||||
|
||||
async function removeUser (req: express.Request, res: express.Response, next: express.NextFunction) {
|
||||
const user = await UserModel.loadById(req.params.id)
|
||||
const user: UserModel = res.locals.user
|
||||
|
||||
await user.destroy()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue