Vulcan/server/users.js

25 lines
684 B
JavaScript
Raw Normal View History

2012-10-04 13:30:57 +09:00
Accounts.onCreateUser(function(options, extra, user){
2012-10-01 13:08:46 +10:00
_.extend(user, extra);
2012-10-01 11:18:05 +10:00
user.karma = 0;
2012-10-01 13:08:46 +10:00
user.profile = user.profile || {};
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
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-09-18 12:21:43 +09:00
});