mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-24 01:29:35 +02:00
Migrate group submit form to zod
GitOrigin-RevId: c6cd882e6446730ad6a4b165871eb3148bd2fb16
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
// ts-check
|
||||
import SubscriptionGroupHandler from './SubscriptionGroupHandler.js'
|
||||
|
||||
import OError from '@overleaf/o-error'
|
||||
@@ -303,10 +302,19 @@ async function createAddSeatsSubscriptionChange(req, res) {
|
||||
}
|
||||
}
|
||||
|
||||
const submitFormSchema = z.object({
|
||||
body: z.object({
|
||||
adding: z.number().int().min(MAX_NUMBER_OF_USERS),
|
||||
poNumber: z.string().optional(),
|
||||
}),
|
||||
})
|
||||
|
||||
async function submitForm(req, res) {
|
||||
const { body } = validateReq(req, submitFormSchema)
|
||||
const { adding, poNumber } = body
|
||||
|
||||
const userId = SessionManager.getLoggedInUserId(req.session)
|
||||
const userEmail = await UserGetter.promises.getUserEmail(userId)
|
||||
const { adding, poNumber } = req.body
|
||||
|
||||
const { paymentProviderSubscription } =
|
||||
await SubscriptionGroupHandler.promises.getUsersGroupSubscriptionDetails(
|
||||
|
||||
@@ -18,8 +18,6 @@ const subscriptionRateLimiter = new RateLimiter('subscription', {
|
||||
duration: 60,
|
||||
})
|
||||
|
||||
const MAX_NUMBER_OF_USERS = 20
|
||||
|
||||
export default {
|
||||
apply(webRouter, privateApiRouter, publicApiRouter) {
|
||||
if (!Settings.enableSubscriptions) {
|
||||
@@ -79,12 +77,6 @@ export default {
|
||||
|
||||
webRouter.post(
|
||||
'/user/subscription/group/add-users/sales-contact-form',
|
||||
validate({
|
||||
body: Joi.object({
|
||||
adding: Joi.number().integer().min(MAX_NUMBER_OF_USERS).required(),
|
||||
poNumber: Joi.string(),
|
||||
}),
|
||||
}),
|
||||
RateLimiterMiddleware.rateLimit(subscriptionRateLimiter),
|
||||
SubscriptionGroupController.submitForm
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user