From 41ca8be754f3377b2df4af2fc7043e30a5ed2087 Mon Sep 17 00:00:00 2001 From: pierre-lehnen-rc <55164754+pierre-lehnen-rc@users.noreply.github.com> Date: Fri, 21 Aug 2020 22:00:45 -0300 Subject: [PATCH] [FIX] findOrCreateInvite REST endpoint ignoring `days` and `maxUses` params (#18565) --- app/invites/server/functions/findOrCreateInvite.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/invites/server/functions/findOrCreateInvite.js b/app/invites/server/functions/findOrCreateInvite.js index 379a934804a..c875a53906d 100644 --- a/app/invites/server/functions/findOrCreateInvite.js +++ b/app/invites/server/functions/findOrCreateInvite.js @@ -46,14 +46,14 @@ export const findOrCreateInvite = (userId, invite) => { throw new Meteor.Error('error-room-type-not-allowed', 'Cannot create invite links for this room type', { method: 'findOrCreateInvite' }); } - let { days, maxUses } = invite; + const { days = 1, maxUses = 0 } = invite; if (!possibleDays.includes(days)) { - days = 1; + throw new Meteor.Error('invalid-number-of-days', 'Invite should expire in 1, 7, 15 or 30 days, or send 0 to never expire.'); } if (!possibleUses.includes(maxUses)) { - maxUses = 0; + throw new Meteor.Error('invalid-number-of-uses', 'Invite should be valid for 1, 5, 10, 25, 50, 100 or infinite (0) uses.'); } // Before anything, let's check if there's an existing invite with the same settings for the same channel and user and that has not yet expired.