Created
December 8, 2016 14:18
-
-
Save acomito/c58f013275f9be71aea08874d73e33b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Meteor } from 'meteor/meteor'; | |
import { Roles } from 'meteor/alanning:roles'; | |
import { Accounts } from 'meteor/accounts-base'; | |
const users = [{ | |
email: 'admin@admin.com', | |
password: 'password', | |
profile: { | |
name: { first: 'Carl', last: 'Winslow' }, | |
}, | |
roles: ['admin'], | |
}]; | |
users.forEach(({ email, password, profile, roles }) => { | |
const userExists = Meteor.users.findOne({ 'emails.address': email }); | |
if (!userExists) { | |
const userId = Accounts.createUser({ email, password, profile }); | |
Roles.addUsersToRoles(userId, roles); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment