X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=server%2Fcontrollers%2Fapi%2Fusers%2Findex.ts;h=a299167e8de1b75b8d2594bbbdb9a5be356df265;hb=993cef4b6e000ee425087e5195dfe40cd0840243;hp=07edf3727117075bd9136382c53d7356d08b8c1e;hpb=606c946e74211c4123b16087288902226306198d;p=oweals%2Fpeertube.git 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 { usersUpdateValidator } from '../../../middlewares' import { - usersAskResetPasswordValidator, usersBlockingValidator, usersResetPasswordValidator, - usersAskSendVerifyEmailValidator, usersVerifyEmailValidator + usersAskResetPasswordValidator, + usersAskSendVerifyEmailValidator, + usersBlockingValidator, + usersResetPasswordValidator, + usersVerifyEmailValidator } from '../../../middlewares/validators' import { UserModel } from '../../../models/account/user' import { OAuthTokenModel } from '../../../models/oauth/oauth-token' -import { auditLoggerFactory, UserAuditView } from '../../../helpers/audit-logger' +import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '../../../helpers/audit-logger' import { meRouter } from './me' const auditLogger = auditLoggerFactory('users') @@ -166,7 +169,7 @@ async function createUser (req: express.Request, res: express.Response) { const { user, account } = await createUserAccountAndChannel(userToCreate) - auditLogger.create(res.locals.oauth.token.User.Account.Actor.getIdentifier(), new UserAuditView(user.toFormattedJSON())) + auditLogger.create(getAuditIdFromRes(res), new UserAuditView(user.toFormattedJSON())) logger.info('User %s with its channel and account created.', body.username) return res.json({ @@ -245,7 +248,7 @@ async function removeUser (req: express.Request, res: express.Response, next: ex await user.destroy() - auditLogger.delete(res.locals.oauth.token.User.Account.Actor.getIdentifier(), new UserAuditView(user.toFormattedJSON())) + auditLogger.delete(getAuditIdFromRes(res), new UserAuditView(user.toFormattedJSON())) return res.sendStatus(204) } @@ -269,7 +272,7 @@ async function updateUser (req: express.Request, res: express.Response, next: ex } auditLogger.update( - res.locals.oauth.token.User.Account.Actor.getIdentifier(), + getAuditIdFromRes(res), new UserAuditView(user.toFormattedJSON()), oldUserAuditView ) @@ -341,7 +344,7 @@ async function changeUserBlock (res: express.Response, user: UserModel, block: b await Emailer.Instance.addUserBlockJob(user, block, reason) auditLogger.update( - res.locals.oauth.token.User.Account.Actor.getIdentifier(), + getAuditIdFromRes(res), new UserAuditView(user.toFormattedJSON()), oldUserAuditView )