Vulcan/server/users.js
Sacha Greif cc61f38d7c tweaks
2012-11-21 12:30:45 +09:00

42 lines
No EOL
1.2 KiB
JavaScript

Accounts.onCreateUser(function(options, user){
user.profile = options.profile || {};
user.karma = 0;
// users start pending, need to be invited
user.isInvited = false
if (options.email)
user.profile.email = options.email;
if (user.profile.email)
user.email_hash = CryptoJS.MD5(user.profile.email.trim().toLowerCase()).toString();
if (!user.profile.name)
user.profile.name = user.username;
// if this is the first user ever, make them an admin
if ( !Meteor.users.find().count() )
user.isAdmin = true;
return user;
});
// FIXME -- don't use this yet, until a) we are sure it's the right approach
// b) we also update their profile at the same time.
Meteor.methods({
changeEmail: function(newEmail) {
Meteor.users.update(Meteor.userId(), {$set: {emails: [{address: newEmail}]}});
},
numberOfPostsToday: function(){
console.log(numberOfItemsInPast24Hours(Meteor.user(), Posts));
},
numberOfCommentsToday: function(){
console.log(numberOfItemsInPast24Hours(Meteor.user(), Comments));
},
testEmail: function(){
console.log('////////////////email test…');
Email.send({from: 'info@sachagreif.com', to: 'sacha357@gmail.com', subject: 'mailgun test', text: 'lorem ipsum dolor'});
}
});