Blame view

imports/server/fixtures.js 626 Bytes
cac7cbc73   tmcdeveloper   4.1.0 release
1
2
3
  import { Meteor } from 'meteor/meteor';
  import { Roles } from 'meteor/alanning:roles';
  import { Accounts } from 'meteor/accounts-base';
d608ac719   themeteorchef   adjust spacing to...
4
  if (!Meteor.isProduction) {
1850fc25b   Michel Floyd   Prevent setting u...
5
6
7
8
    const users = [{
      email: 'admin@admin.com',
      password: 'password',
      profile: {
d608ac719   themeteorchef   adjust spacing to...
9
        name: { first: 'Carl', last: 'Winslow' },
1850fc25b   Michel Floyd   Prevent setting u...
10
11
12
      },
      roles: ['admin'],
    }];
2b1ad7917   tmcdeveloper   wip moving to Met...
13

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

1850fc25b   Michel Floyd   Prevent setting u...
17
18
19
20
21
22
      if (!userExists) {
        const userId = Accounts.createUser({ email, password, profile });
        Roles.addUsersToRoles(userId, roles);
      }
    });
  }