-import * as express from 'express'
-import * as RateLimit from 'express-rate-limit'
+import express from 'express'
+import RateLimit from 'express-rate-limit'
import { tokensRouter } from '@server/controllers/api/users/token'
import { Hooks } from '@server/lib/plugins/hooks'
import { OAuthTokenModel } from '@server/models/oauth/oauth-token'
import { MUser, MUserAccountDefault } from '@server/types/models'
-import { UserCreate, UserCreateResult, UserRight, UserRole, UserUpdate } from '../../../../shared'
-import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
-import { UserAdminFlag } from '../../../../shared/models/users/user-flag.model'
-import { UserRegister } from '../../../../shared/models/users/user-register.model'
+import { HttpStatusCode, UserAdminFlag, UserCreate, UserCreateResult, UserRegister, UserRight, UserRole, UserUpdate } from '@shared/models'
import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '../../../helpers/audit-logger'
import { logger } from '../../../helpers/logger'
import { generateRandomString, getFormattedObjects } from '../../../helpers/utils'
password: body.password,
email: body.email,
nsfwPolicy: CONFIG.INSTANCE.DEFAULT_NSFW_POLICY,
+ p2pEnabled: CONFIG.DEFAULTS.P2P.WEBAPP.ENABLED,
autoPlayVideo: true,
role: body.role,
videoQuota: body.videoQuota,
logger.info('Sending to user %s a create password email', body.username)
const verificationString = await Redis.Instance.setCreatePasswordVerificationString(user.id)
const url = WEBSERVER.URL + '/reset-password?userId=' + user.id + '&verificationString=' + verificationString
- await Emailer.Instance.addPasswordCreateEmailJob(userToCreate.username, user.email, url)
+ Emailer.Instance.addPasswordCreateEmailJob(userToCreate.username, user.email, url)
}
- Hooks.runAction('action:api.user.created', { body, user, account, videoChannel })
+ Hooks.runAction('action:api.user.created', { body, user, account, videoChannel, req, res })
return res.json({
user: {
password: body.password,
email: body.email,
nsfwPolicy: CONFIG.INSTANCE.DEFAULT_NSFW_POLICY,
+ p2pEnabled: CONFIG.DEFAULTS.P2P.WEBAPP.ENABLED,
autoPlayVideo: true,
role: UserRole.USER,
videoQuota: CONFIG.USER.VIDEO_QUOTA,
Notifier.Instance.notifyOnNewUserRegistration(user)
- Hooks.runAction('action:api.user.registered', { body, user, account, videoChannel })
+ Hooks.runAction('action:api.user.registered', { body, user, account, videoChannel, req, res })
return res.type('json').status(HttpStatusCode.NO_CONTENT_204).end()
}
await changeUserBlock(res, user, false)
- Hooks.runAction('action:api.user.unblocked', { user })
+ Hooks.runAction('action:api.user.unblocked', { user, req, res })
return res.status(HttpStatusCode.NO_CONTENT_204).end()
}
await changeUserBlock(res, user, true, reason)
- Hooks.runAction('action:api.user.blocked', { user })
+ Hooks.runAction('action:api.user.blocked', { user, req, res })
return res.status(HttpStatusCode.NO_CONTENT_204).end()
}
await user.destroy({ transaction: t })
})
- Hooks.runAction('action:api.user.deleted', { user })
+ Hooks.runAction('action:api.user.deleted', { user, req, res })
return res.status(HttpStatusCode.NO_CONTENT_204).end()
}
auditLogger.update(getAuditIdFromRes(res), new UserAuditView(user.toFormattedJSON()), oldUserAuditView)
- Hooks.runAction('action:api.user.updated', { user })
+ Hooks.runAction('action:api.user.updated', { user, req, res })
// Don't need to send this update to followers, these attributes are not federated