diff options
author | Chocobozzz <me@florianbigard.com> | 2021-01-04 09:54:48 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-01-04 09:54:48 +0100 |
commit | 2dbc170da35c9f88770653cd3114f4c59d482094 (patch) | |
tree | 0befce119e2fe3a750b000cb8b971d12e41550a3 /server/controllers/api | |
parent | afd4ee86ddb97f8d49585fddd318bedcd3ad55b8 (diff) | |
download | PeerTube-2dbc170da35c9f88770653cd3114f4c59d482094.tar.gz PeerTube-2dbc170da35c9f88770653cd3114f4c59d482094.tar.zst PeerTube-2dbc170da35c9f88770653cd3114f4c59d482094.zip |
Add missing audit log if the user deletes its account
Diffstat (limited to 'server/controllers/api')
-rw-r--r-- | server/controllers/api/users/index.ts | 4 | ||||
-rw-r--r-- | server/controllers/api/users/me.ts | 9 |
2 files changed, 9 insertions, 4 deletions
diff --git a/server/controllers/api/users/index.ts b/server/controllers/api/users/index.ts index d743a9912..c3190e731 100644 --- a/server/controllers/api/users/index.ts +++ b/server/controllers/api/users/index.ts | |||
@@ -305,10 +305,10 @@ async function listUsers (req: express.Request, res: express.Response) { | |||
305 | async function removeUser (req: express.Request, res: express.Response) { | 305 | async function removeUser (req: express.Request, res: express.Response) { |
306 | const user = res.locals.user | 306 | const user = res.locals.user |
307 | 307 | ||
308 | await user.destroy() | ||
309 | |||
310 | auditLogger.delete(getAuditIdFromRes(res), new UserAuditView(user.toFormattedJSON())) | 308 | auditLogger.delete(getAuditIdFromRes(res), new UserAuditView(user.toFormattedJSON())) |
311 | 309 | ||
310 | await user.destroy() | ||
311 | |||
312 | Hooks.runAction('action:api.user.deleted', { user }) | 312 | Hooks.runAction('action:api.user.deleted', { user }) |
313 | 313 | ||
314 | return res.sendStatus(HttpStatusCode.NO_CONTENT_204) | 314 | return res.sendStatus(HttpStatusCode.NO_CONTENT_204) |
diff --git a/server/controllers/api/users/me.ts b/server/controllers/api/users/me.ts index 3d2a325fe..b786d7f59 100644 --- a/server/controllers/api/users/me.ts +++ b/server/controllers/api/users/me.ts | |||
@@ -1,6 +1,8 @@ | |||
1 | import 'multer' | 1 | import 'multer' |
2 | import * as express from 'express' | 2 | import * as express from 'express' |
3 | import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '@server/helpers/audit-logger' | ||
3 | import { UserUpdateMe, UserVideoRate as FormattedUserVideoRate, VideoSortField } from '../../../../shared' | 4 | import { UserUpdateMe, UserVideoRate as FormattedUserVideoRate, VideoSortField } from '../../../../shared' |
5 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
4 | import { UserVideoQuota } from '../../../../shared/models/users/user-video-quota.model' | 6 | import { UserVideoQuota } from '../../../../shared/models/users/user-video-quota.model' |
5 | import { createReqFiles } from '../../../helpers/express-utils' | 7 | import { createReqFiles } from '../../../helpers/express-utils' |
6 | import { getFormattedObjects } from '../../../helpers/utils' | 8 | import { getFormattedObjects } from '../../../helpers/utils' |
@@ -28,7 +30,8 @@ import { AccountVideoRateModel } from '../../../models/account/account-video-rat | |||
28 | import { UserModel } from '../../../models/account/user' | 30 | import { UserModel } from '../../../models/account/user' |
29 | import { VideoModel } from '../../../models/video/video' | 31 | import { VideoModel } from '../../../models/video/video' |
30 | import { VideoImportModel } from '../../../models/video/video-import' | 32 | import { VideoImportModel } from '../../../models/video/video-import' |
31 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 33 | |
34 | const auditLogger = auditLoggerFactory('users') | ||
32 | 35 | ||
33 | const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR }) | 36 | const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR }) |
34 | 37 | ||
@@ -159,7 +162,9 @@ async function getUserVideoRating (req: express.Request, res: express.Response) | |||
159 | } | 162 | } |
160 | 163 | ||
161 | async function deleteMe (req: express.Request, res: express.Response) { | 164 | async function deleteMe (req: express.Request, res: express.Response) { |
162 | const user = res.locals.oauth.token.User | 165 | const user = await UserModel.loadByIdWithChannels(res.locals.oauth.token.User.id) |
166 | |||
167 | auditLogger.delete(getAuditIdFromRes(res), new UserAuditView(user.toFormattedJSON())) | ||
163 | 168 | ||
164 | await user.destroy() | 169 | await user.destroy() |
165 | 170 | ||