invitationCodes.js 784 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. InvitationCodes = new Mongo.Collection('invitation_codes');
  2. InvitationCodes.attachSchema(new SimpleSchema({
  3. code: {
  4. type: String,
  5. },
  6. email: {
  7. type: String,
  8. unique: true,
  9. regEx: SimpleSchema.RegEx.Email,
  10. },
  11. createdAt: {
  12. type: Date,
  13. denyUpdate: false,
  14. },
  15. // always be the admin if only one admin
  16. authorId: {
  17. type: String,
  18. },
  19. boardsToBeInvited: {
  20. type: [String],
  21. optional: true,
  22. },
  23. valid: {
  24. type: Boolean,
  25. defaultValue: true,
  26. },
  27. }));
  28. InvitationCodes.helpers({
  29. author(){
  30. return Users.findOne(this.authorId);
  31. },
  32. });
  33. // InvitationCodes.before.insert((userId, doc) => {
  34. // doc.createdAt = new Date();
  35. // doc.authorId = userId;
  36. // });
  37. if (Meteor.isServer) {
  38. Boards.deny({
  39. fetch: ['members'],
  40. });
  41. }