aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/users/index.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-09-19 17:02:16 +0200
committerChocobozzz <me@florianbigard.com>2018-09-19 17:02:27 +0200
commit993cef4b6e000ee425087e5195dfe40cd0840243 (patch)
tree9bddf4a2f4fad0ac8cbb9d79445c1c1ec36bd305 /server/controllers/api/users/index.ts
parent606c946e74211c4123b16087288902226306198d (diff)
downloadPeerTube-993cef4b6e000ee425087e5195dfe40cd0840243.tar.gz
PeerTube-993cef4b6e000ee425087e5195dfe40cd0840243.tar.zst
PeerTube-993cef4b6e000ee425087e5195dfe40cd0840243.zip
Refractor audit user identifier
Diffstat (limited to 'server/controllers/api/users/index.ts')
-rw-r--r--server/controllers/api/users/index.ts17
1 files changed, 10 insertions, 7 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 )