summaryrefslogtreecommitdiffstats
path: root/models/invitationCodes.js
blob: 5761977a63bd3389ee6f782ba33092e0d4f6bf2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
InvitationCodes = new Mongo.Collection('invitation_codes');

InvitationCodes.attachSchema(new SimpleSchema({
  code: {
    type: String,
  },
  email: {
    type: String,
    unique: true,
    regEx: SimpleSchema.RegEx.Email,
  },
  createdAt: {
    type: Date,
    denyUpdate: false,
  },
  // always be the admin if only one admin
  authorId: {
    type: String,
  },
  boardsToBeInvited: {
    type: [String],
    optional: true,
  },
  valid: {
    type: Boolean,
    defaultValue: true,
  },
}));

InvitationCodes.helpers({
  author(){
    return Users.findOne(this.authorId);
  },
});

// InvitationCodes.before.insert((userId, doc) => {
  // doc.createdAt = new Date();
  // doc.authorId = userId;
// });

if (Meteor.isServer) {
  Boards.deny({
    fetch: ['members'],
  });
}