This is branching from my previous question sent earlier Retrieve value from html 'value' attribute. I am now trying to insert a session variable value into field named 'userType' upon user creation. I have kept the insecure package so I can immediately perform Meteor.users.find().count(); in the console. So far, the users are not being created.
Am I inserting the session variable value the correct way, should this session value be inserted server side with Accounts.onCreateUser?
The client js
Template.joinForm.events({
'submit .form-join': function(e, t) {
e.preventDefault();
var firstName = t.find('#firstName').value,
lastName = t.find('#email').value,
email = t.find('#email').value,
password = t.find('#password').value,
username = firstName + '.' + lastName,
profile = {
name: firstName + ' ' + lastName,
userType: selectedUserType
};
Accounts.createUser({
email: email,
username: username,
password: password,
profile: profile
}, function(error) {
if (error) {
alert(error);
} else {
Router.go('/');
}
});
}
});
I have made the 'userType' session variable global, please see as follows...
Template.authJoinType.events({
'click div.join-type-inner': function(e, tmpl) {
userType = $(e.target).attr("value");
Session.set('userType', userType);
selectedUserType = Session.get('userType');
console.log(selectedUserType);
}
});