[FIX] findOrCreateInvite REST endpoint ignoring `days` and `maxUses` params (#18565)

pull/18643/head
pierre-lehnen-rc 5 years ago committed by GitHub
parent b913621b57
commit 41ca8be754
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      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.

Loading…
Cancel
Save