Skip to content

Instantly share code, notes, and snippets.

@digilord
Created March 14, 2014 16:01
Show Gist options
  • Save digilord/9550688 to your computer and use it in GitHub Desktop.
Save digilord/9550688 to your computer and use it in GitHub Desktop.
creationTime = new Date()
profile =
name: ''
stripeId: ''
created: creationTime.getTime()
address: ''
city: ''
state: ''
country: ''
limit: 2
normalizeUsers = () ->
for user in Meteor.users.find().fetch()
console.log "Processing #{user.username}"
if not user.profile?
profile.name = user.username
Meteor.users.update({_id: user._id}, {$set:{profile: new_profile}})
console.log "Users profile missing. Adding profile."
else
# Merge the users profile with the template from above.
users_profile = user.profile
new_profile = Object.merge(users_profile, profile, true, false)
Meteor.users.update({_id: user._id}, {$set:{profile: new_profile}})
console.log "Merging stock profile with existing users profile."
if not user.emails?
email =
address: user.username
verified: true
# Meteor.users.update({_id: user._id}, {$set:{emails: [email]}})
console.log '----------------'
console.log 'Adding roles to Daniel, Adam, and Justin'
admins = []
admins.push Meteor.users.findOne({username: '[email protected]'})
admins.push Meteor.users.findOne({username: '[email protected]'})
admins.push Meteor.users.findOne({username: '[email protected]'})
for admin in admins
if admin?
console.log "Processing #{admin.username}"
Roles.addUsersToRoles(admin._id, ['admin'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment