Blame view
imports/startup/server/fixtures.js
796 Bytes
cac7cbc73
|
1 2 3 |
import { Meteor } from 'meteor/meteor'; import { Roles } from 'meteor/alanning:roles'; import { Accounts } from 'meteor/accounts-base'; |
1850fc25b
|
4 5 6 7 8 9 10 11 12 13 14 15 |
/* Create a default admin user but *only in non-production environments!* * This is to avoid a base app being deployed in production with a known generic admin user */ if ( !Meteor.isProduction ) { const users = [{ email: 'admin@admin.com', password: 'password', profile: { name: {first: 'Carl', last: 'Winslow'}, }, roles: ['admin'], }]; |
2b1ad7917
|
16 |
|
1850fc25b
|
17 18 |
users.forEach(({ email, password, profile, roles }) => { const userExists = Meteor.users.findOne({ 'emails.address': email }); |
2b1ad7917
|
19 |
|
1850fc25b
|
20 21 22 23 24 25 |
if (!userExists) { const userId = Accounts.createUser({ email, password, profile }); Roles.addUsersToRoles(userId, roles); } }); } |