diff --git a/app/invites/server/functions/findOrCreateInvite.js b/app/invites/server/functions/findOrCreateInvite.js index 379a934804a103ecc9a20531b7dfd417ae8fe058..c875a53906d0a41fc2b199a36d47c75aa14c1a8b 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.