2012-10-18 17:20:20 +09:00
|
|
|
Accounts.onCreateUser(function(options, user){
|
2012-10-18 17:43:03 +09:00
|
|
|
user.profile = options.profile || {};
|
2012-10-01 11:18:05 +10:00
|
|
|
user.karma = 0;
|
2012-10-01 13:08:46 +10:00
|
|
|
|
2012-10-19 12:42:28 +09:00
|
|
|
|
|
|
|
|
2012-10-05 14:08:46 +09:00
|
|
|
// users start pending, need to be invited
|
2012-10-05 13:59:40 +09:00
|
|
|
user.isInvited = false
|
2012-10-04 11:53:15 +10:00
|
|
|
|
2012-10-01 11:18:05 +10:00
|
|
|
if (options.email)
|
2012-10-01 13:08:46 +10:00
|
|
|
user.profile.email = options.email;
|
|
|
|
|
|
|
|
if (user.profile.email)
|
|
|
|
user.email_hash = CryptoJS.MD5(user.profile.email.trim().toLowerCase()).toString();
|
2012-10-01 11:18:05 +10:00
|
|
|
|
2012-10-01 13:08:46 +10:00
|
|
|
if (!user.profile.name)
|
|
|
|
user.profile.name = user.username;
|
2012-10-01 11:18:05 +10:00
|
|
|
|
2012-10-19 12:42:28 +09:00
|
|
|
// if this is the first user ever, make them an admin
|
|
|
|
if ( !Meteor.users.find().count() )
|
|
|
|
user.isAdmin = true;
|
2012-10-18 17:43:03 +09:00
|
|
|
|
2012-10-01 11:18:05 +10:00
|
|
|
return user;
|
2012-10-01 13:08:46 +10:00
|
|
|
});
|
|
|
|
|
|
|
|
// 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}]}});
|
2012-10-30 12:01:11 +09:00
|
|
|
},
|
|
|
|
numberOfPostsToday: function(){
|
|
|
|
console.log(numberOfItemsInPast24Hours(Meteor.user(), Posts));
|
|
|
|
},
|
|
|
|
numberOfCommentsToday: function(){
|
|
|
|
console.log(numberOfItemsInPast24Hours(Meteor.user(), Comments));
|
2012-11-21 12:30:45 +09:00
|
|
|
},
|
|
|
|
testEmail: function(){
|
|
|
|
console.log('////////////////email test…');
|
|
|
|
Email.send({from: 'info@sachagreif.com', to: 'sacha357@gmail.com', subject: 'mailgun test', text: 'lorem ipsum dolor'});
|
2012-10-01 13:08:46 +10:00
|
|
|
}
|
2012-09-18 12:21:43 +09:00
|
|
|
});
|