aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/users
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/users')
-rw-r--r--server/controllers/api/users/index.ts17
-rw-r--r--server/controllers/api/users/me.ts15
2 files changed, 18 insertions, 14 deletions
diff --git a/server/controllers/api/users/index.ts b/server/controllers/api/users/index.ts
index 07edf3727..a299167e8 100644
--- a/server/controllers/api/users/index.ts
+++ b/server/controllers/api/users/index.ts
@@ -27,12 +27,15 @@ import {
27 usersUpdateValidator 27 usersUpdateValidator
28} from '../../../middlewares' 28} from '../../../middlewares'
29import { 29import {
30 usersAskResetPasswordValidator, usersBlockingValidator, usersResetPasswordValidator, 30 usersAskResetPasswordValidator,
31 usersAskSendVerifyEmailValidator, usersVerifyEmailValidator 31 usersAskSendVerifyEmailValidator,
32 usersBlockingValidator,
33 usersResetPasswordValidator,
34 usersVerifyEmailValidator
32} from '../../../middlewares/validators' 35} from '../../../middlewares/validators'
33import { UserModel } from '../../../models/account/user' 36import { UserModel } from '../../../models/account/user'
34import { OAuthTokenModel } from '../../../models/oauth/oauth-token' 37import { OAuthTokenModel } from '../../../models/oauth/oauth-token'
35import { auditLoggerFactory, UserAuditView } from '../../../helpers/audit-logger' 38import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '../../../helpers/audit-logger'
36import { meRouter } from './me' 39import { meRouter } from './me'
37 40
38const auditLogger = auditLoggerFactory('users') 41const auditLogger = auditLoggerFactory('users')
@@ -166,7 +169,7 @@ async function createUser (req: express.Request, res: express.Response) {
166 169
167 const { user, account } = await createUserAccountAndChannel(userToCreate) 170 const { user, account } = await createUserAccountAndChannel(userToCreate)
168 171
169 auditLogger.create(res.locals.oauth.token.User.Account.Actor.getIdentifier(), new UserAuditView(user.toFormattedJSON())) 172 auditLogger.create(getAuditIdFromRes(res), new UserAuditView(user.toFormattedJSON()))
170 logger.info('User %s with its channel and account created.', body.username) 173 logger.info('User %s with its channel and account created.', body.username)
171 174
172 return res.json({ 175 return res.json({
@@ -245,7 +248,7 @@ async function removeUser (req: express.Request, res: express.Response, next: ex
245 248
246 await user.destroy() 249 await user.destroy()
247 250
248 auditLogger.delete(res.locals.oauth.token.User.Account.Actor.getIdentifier(), new UserAuditView(user.toFormattedJSON())) 251 auditLogger.delete(getAuditIdFromRes(res), new UserAuditView(user.toFormattedJSON()))
249 252
250 return res.sendStatus(204) 253 return res.sendStatus(204)
251} 254}
@@ -269,7 +272,7 @@ async function updateUser (req: express.Request, res: express.Response, next: ex
269 } 272 }
270 273
271 auditLogger.update( 274 auditLogger.update(
272 res.locals.oauth.token.User.Account.Actor.getIdentifier(), 275 getAuditIdFromRes(res),
273 new UserAuditView(user.toFormattedJSON()), 276 new UserAuditView(user.toFormattedJSON()),
274 oldUserAuditView 277 oldUserAuditView
275 ) 278 )
@@ -341,7 +344,7 @@ async function changeUserBlock (res: express.Response, user: UserModel, block: b
341 await Emailer.Instance.addUserBlockJob(user, block, reason) 344 await Emailer.Instance.addUserBlockJob(user, block, reason)
342 345
343 auditLogger.update( 346 auditLogger.update(
344 res.locals.oauth.token.User.Account.Actor.getIdentifier(), 347 getAuditIdFromRes(res),
345 new UserAuditView(user.toFormattedJSON()), 348 new UserAuditView(user.toFormattedJSON()),
346 oldUserAuditView 349 oldUserAuditView
347 ) 350 )
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'
5import { CONFIG, IMAGE_MIMETYPE_EXT, sequelizeTypescript } from '../../../initializers' 5import { CONFIG, IMAGE_MIMETYPE_EXT, sequelizeTypescript } from '../../../initializers'
6import { sendUpdateActor } from '../../../lib/activitypub/send' 6import { sendUpdateActor } from '../../../lib/activitypub/send'
7import { 7import {
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'
19import { 20import {
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'
26import { AccountVideoRateModel } from '../../../models/account/account-video-rate' 27import { AccountVideoRateModel } from '../../../models/account/account-video-rate'
27import { UserModel } from '../../../models/account/user' 28import { UserModel } from '../../../models/account/user'
@@ -31,7 +32,7 @@ import { buildNSFWFilter, createReqFiles } from '../../../helpers/express-utils'
31import { UserVideoQuota } from '../../../../shared/models/users/user-video-quota.model' 32import { UserVideoQuota } from '../../../../shared/models/users/user-video-quota.model'
32import { updateAvatarValidator } from '../../../middlewares/validators/avatar' 33import { updateAvatarValidator } from '../../../middlewares/validators/avatar'
33import { updateActorAvatarFile } from '../../../lib/avatar' 34import { updateActorAvatarFile } from '../../../lib/avatar'
34import { auditLoggerFactory, UserAuditView } from '../../../helpers/audit-logger' 35import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '../../../helpers/audit-logger'
35import { VideoImportModel } from '../../../models/video/video-import' 36import { VideoImportModel } from '../../../models/video/video-import'
36import { VideoFilter } from '../../../../shared/models/videos/video-query.type' 37import { VideoFilter } from '../../../../shared/models/videos/video-query.type'
37import { ActorFollowModel } from '../../../models/activitypub/actor-follow' 38import { 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 )