Blame view

imports/server/fixtures.js 898 Bytes
d0099dd88   Deepak   student detail pa...
1
2
3
4
  import { Meteor }                         from 'meteor/meteor';
  import { Roles }                          from 'meteor/alanning:roles';
  import { Accounts }                       from 'meteor/accounts-base';
  import { Orgs }                           from '/imports/collections/orgs/index';
cac7cbc73   tmcdeveloper   4.1.0 release
5

d608ac719   themeteorchef   adjust spacing to...
6
  if (!Meteor.isProduction) {
1850fc25b   Michel Floyd   Prevent setting u...
7
8
9
10
    const users = [{
      email: 'admin@admin.com',
      password: 'password',
      profile: {
d608ac719   themeteorchef   adjust spacing to...
11
        name: { first: 'Carl', last: 'Winslow' },
1850fc25b   Michel Floyd   Prevent setting u...
12
13
14
      },
      roles: ['admin'],
    }];
2b1ad7917   tmcdeveloper   wip moving to Met...
15

1850fc25b   Michel Floyd   Prevent setting u...
16
17
    users.forEach(({ email, password, profile, roles }) => {
      const userExists = Meteor.users.findOne({ 'emails.address': email });
2b1ad7917   tmcdeveloper   wip moving to Met...
18

1850fc25b   Michel Floyd   Prevent setting u...
19
20
21
      if (!userExists) {
        const userId = Accounts.createUser({ email, password, profile });
        Roles.addUsersToRoles(userId, roles);
d0099dd88   Deepak   student detail pa...
22
23
24
25
26
27
        const org = [{
          name: 'yd',
          slug: 'yd',
          "users.userId": userId
        }];
        Orgs.inser
1850fc25b   Michel Floyd   Prevent setting u...
28
29
30
      }
    });
  }