Skip to content

Instantly share code, notes, and snippets.

@acomito
Created December 8, 2016 14:18
Show Gist options
  • Save acomito/c58f013275f9be71aea08874d73e33b3 to your computer and use it in GitHub Desktop.
Save acomito/c58f013275f9be71aea08874d73e33b3 to your computer and use it in GitHub Desktop.
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