diff options
Diffstat (limited to 'server/controllers/api')
-rw-r--r-- | server/controllers/api/users.ts | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/server/controllers/api/users.ts b/server/controllers/api/users.ts index 36bf0e0fe..3d2586c3a 100644 --- a/server/controllers/api/users.ts +++ b/server/controllers/api/users.ts | |||
@@ -30,6 +30,7 @@ import { | |||
30 | usersVideoRatingValidator | 30 | usersVideoRatingValidator |
31 | } from '../../middlewares' | 31 | } from '../../middlewares' |
32 | import { | 32 | import { |
33 | deleteMeValidator, | ||
33 | usersAskResetPasswordValidator, | 34 | usersAskResetPasswordValidator, |
34 | usersResetPasswordValidator, | 35 | usersResetPasswordValidator, |
35 | videoImportsSortValidator, | 36 | videoImportsSortValidator, |
@@ -62,6 +63,11 @@ usersRouter.get('/me', | |||
62 | authenticate, | 63 | authenticate, |
63 | asyncMiddleware(getUserInformation) | 64 | asyncMiddleware(getUserInformation) |
64 | ) | 65 | ) |
66 | usersRouter.delete('/me', | ||
67 | authenticate, | ||
68 | asyncMiddleware(deleteMeValidator), | ||
69 | asyncMiddleware(deleteMe) | ||
70 | ) | ||
65 | 71 | ||
66 | usersRouter.get('/me/video-quota-used', | 72 | usersRouter.get('/me/video-quota-used', |
67 | authenticate, | 73 | authenticate, |
@@ -296,8 +302,18 @@ async function listUsers (req: express.Request, res: express.Response, next: exp | |||
296 | return res.json(getFormattedObjects(resultList.data, resultList.total)) | 302 | return res.json(getFormattedObjects(resultList.data, resultList.total)) |
297 | } | 303 | } |
298 | 304 | ||
305 | async function deleteMe (req: express.Request, res: express.Response) { | ||
306 | const user: UserModel = res.locals.oauth.token.User | ||
307 | |||
308 | await user.destroy() | ||
309 | |||
310 | auditLogger.delete(res.locals.oauth.token.User.Account.Actor.getIdentifier(), new UserAuditView(user.toFormattedJSON())) | ||
311 | |||
312 | return res.sendStatus(204) | ||
313 | } | ||
314 | |||
299 | async function removeUser (req: express.Request, res: express.Response, next: express.NextFunction) { | 315 | async function removeUser (req: express.Request, res: express.Response, next: express.NextFunction) { |
300 | const user = await UserModel.loadById(req.params.id) | 316 | const user: UserModel = res.locals.user |
301 | 317 | ||
302 | await user.destroy() | 318 | await user.destroy() |
303 | 319 | ||