2013-11-14 10:04:11 +09:00
|
|
|
Template.user_email.helpers({
|
|
|
|
user: function(){
|
|
|
|
return Meteor.user();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-11-24 16:13:53 +02:00
|
|
|
Template.user_email.events({
|
2012-10-01 13:57:52 +09:00
|
|
|
'submit form': function(e){
|
|
|
|
e.preventDefault();
|
2013-11-06 01:01:56 +01:00
|
|
|
if(!Meteor.user()) throwError(i18n.t('You must be logged in.'));
|
2012-10-01 13:59:23 +09:00
|
|
|
var $target=$(e.target);
|
2012-10-11 08:23:52 +09:00
|
|
|
var user=Session.get('selectedUserId')? Meteor.users.findOne(Session.get('selectedUserId')) : Meteor.user();
|
2012-10-01 13:57:52 +09:00
|
|
|
var update = {
|
2014-05-04 17:21:52 +01:00
|
|
|
"profile.email": $target.find('[name=email]').val(),
|
2014-05-04 18:48:47 +01:00
|
|
|
"username": $target.find('[name=username]').val(),
|
|
|
|
"slug": $target.find('[name=username]').val()
|
2012-10-01 13:57:52 +09:00
|
|
|
};
|
2014-05-04 17:21:52 +01:00
|
|
|
|
2012-10-01 13:57:52 +09:00
|
|
|
// TODO: enable change email
|
2012-10-01 13:59:23 +09:00
|
|
|
var email = $target.find('[name=email]').val();
|
2012-10-01 13:57:52 +09:00
|
|
|
|
|
|
|
Meteor.users.update(user._id, {
|
|
|
|
$set: update
|
|
|
|
}, function(error){
|
|
|
|
if(error){
|
|
|
|
throwError(error.reason);
|
|
|
|
} else {
|
2013-11-06 01:01:56 +01:00
|
|
|
throwError(i18n.t('Thanks for signing up!'));
|
2013-10-05 11:43:07 +09:00
|
|
|
Meteor.call('addCurrentUserToMailChimpList');
|
2012-10-01 14:52:32 +09:00
|
|
|
trackEvent("new sign-up", {'userId': user._id, 'auth':'twitter'});
|
2013-10-09 21:49:02 +09:00
|
|
|
Router.go('/');
|
2012-10-01 13:57:52 +09:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2013-11-24 16:13:53 +02:00
|
|
|
});
|