Created
March 14, 2014 16:01
-
-
Save digilord/9550688 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
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