diff options
author | Chocobozzz <me@florianbigard.com> | 2018-09-19 17:02:16 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-09-19 17:02:27 +0200 |
commit | 993cef4b6e000ee425087e5195dfe40cd0840243 (patch) | |
tree | 9bddf4a2f4fad0ac8cbb9d79445c1c1ec36bd305 /server/controllers/api/users/me.ts | |
parent | 606c946e74211c4123b16087288902226306198d (diff) | |
download | PeerTube-993cef4b6e000ee425087e5195dfe40cd0840243.tar.gz PeerTube-993cef4b6e000ee425087e5195dfe40cd0840243.tar.zst PeerTube-993cef4b6e000ee425087e5195dfe40cd0840243.zip |
Refractor audit user identifier
Diffstat (limited to 'server/controllers/api/users/me.ts')
-rw-r--r-- | server/controllers/api/users/me.ts | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/server/controllers/api/users/me.ts b/server/controllers/api/users/me.ts index 113563c39..d4b7e3715 100644 --- a/server/controllers/api/users/me.ts +++ b/server/controllers/api/users/me.ts | |||
@@ -5,7 +5,8 @@ import { getFormattedObjects } from '../../../helpers/utils' | |||
5 | import { CONFIG, IMAGE_MIMETYPE_EXT, sequelizeTypescript } from '../../../initializers' | 5 | import { CONFIG, IMAGE_MIMETYPE_EXT, sequelizeTypescript } from '../../../initializers' |
6 | import { sendUpdateActor } from '../../../lib/activitypub/send' | 6 | import { sendUpdateActor } from '../../../lib/activitypub/send' |
7 | import { | 7 | import { |
8 | asyncMiddleware, asyncRetryTransactionMiddleware, | 8 | asyncMiddleware, |
9 | asyncRetryTransactionMiddleware, | ||
9 | authenticate, | 10 | authenticate, |
10 | commonVideosFiltersValidator, | 11 | commonVideosFiltersValidator, |
11 | paginationValidator, | 12 | paginationValidator, |
@@ -17,11 +18,11 @@ import { | |||
17 | usersVideoRatingValidator | 18 | usersVideoRatingValidator |
18 | } from '../../../middlewares' | 19 | } from '../../../middlewares' |
19 | import { | 20 | import { |
21 | areSubscriptionsExistValidator, | ||
20 | deleteMeValidator, | 22 | deleteMeValidator, |
21 | userSubscriptionsSortValidator, | 23 | userSubscriptionsSortValidator, |
22 | videoImportsSortValidator, | 24 | videoImportsSortValidator, |
23 | videosSortValidator, | 25 | videosSortValidator |
24 | areSubscriptionsExistValidator | ||
25 | } from '../../../middlewares/validators' | 26 | } from '../../../middlewares/validators' |
26 | import { AccountVideoRateModel } from '../../../models/account/account-video-rate' | 27 | import { AccountVideoRateModel } from '../../../models/account/account-video-rate' |
27 | import { UserModel } from '../../../models/account/user' | 28 | import { UserModel } from '../../../models/account/user' |
@@ -31,7 +32,7 @@ import { buildNSFWFilter, createReqFiles } from '../../../helpers/express-utils' | |||
31 | import { UserVideoQuota } from '../../../../shared/models/users/user-video-quota.model' | 32 | import { UserVideoQuota } from '../../../../shared/models/users/user-video-quota.model' |
32 | import { updateAvatarValidator } from '../../../middlewares/validators/avatar' | 33 | import { updateAvatarValidator } from '../../../middlewares/validators/avatar' |
33 | import { updateActorAvatarFile } from '../../../lib/avatar' | 34 | import { updateActorAvatarFile } from '../../../lib/avatar' |
34 | import { auditLoggerFactory, UserAuditView } from '../../../helpers/audit-logger' | 35 | import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '../../../helpers/audit-logger' |
35 | import { VideoImportModel } from '../../../models/video/video-import' | 36 | import { VideoImportModel } from '../../../models/video/video-import' |
36 | import { VideoFilter } from '../../../../shared/models/videos/video-query.type' | 37 | import { VideoFilter } from '../../../../shared/models/videos/video-query.type' |
37 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' | 38 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' |
@@ -311,7 +312,7 @@ async function deleteMe (req: express.Request, res: express.Response) { | |||
311 | 312 | ||
312 | await user.destroy() | 313 | await user.destroy() |
313 | 314 | ||
314 | auditLogger.delete(res.locals.oauth.token.User.Account.Actor.getIdentifier(), new UserAuditView(user.toFormattedJSON())) | 315 | auditLogger.delete(getAuditIdFromRes(res), new UserAuditView(user.toFormattedJSON())) |
315 | 316 | ||
316 | return res.sendStatus(204) | 317 | return res.sendStatus(204) |
317 | } | 318 | } |
@@ -337,7 +338,7 @@ async function updateMe (req: express.Request, res: express.Response, next: expr | |||
337 | await sendUpdateActor(user.Account, t) | 338 | await sendUpdateActor(user.Account, t) |
338 | 339 | ||
339 | auditLogger.update( | 340 | auditLogger.update( |
340 | res.locals.oauth.token.User.Account.Actor.getIdentifier(), | 341 | getAuditIdFromRes(res), |
341 | new UserAuditView(user.toFormattedJSON()), | 342 | new UserAuditView(user.toFormattedJSON()), |
342 | oldUserAuditView | 343 | oldUserAuditView |
343 | ) | 344 | ) |
@@ -355,7 +356,7 @@ async function updateMyAvatar (req: express.Request, res: express.Response, next | |||
355 | const avatar = await updateActorAvatarFile(avatarPhysicalFile, account.Actor, account) | 356 | const avatar = await updateActorAvatarFile(avatarPhysicalFile, account.Actor, account) |
356 | 357 | ||
357 | auditLogger.update( | 358 | auditLogger.update( |
358 | res.locals.oauth.token.User.Account.Actor.getIdentifier(), | 359 | getAuditIdFromRes(res), |
359 | new UserAuditView(user.toFormattedJSON()), | 360 | new UserAuditView(user.toFormattedJSON()), |
360 | oldUserAuditView | 361 | oldUserAuditView |
361 | ) | 362 | ) |