Open mikesjewett opened 9 years ago
@mikesjewett This is what I have in the file and it seems to be working. Let me know where the discrepency is and I'll update it in the material.
Template.loginPage.events({
'submit .login-form': function(e) {
e.preventDefault();
var un = $(e.target).find('[name="username"]');
var pw = $(e.target).find('[name="password"]');
var nu = $(e.target).find('[name="newuser"]');
var fieldsPopulated = function() {
return un.val() !== '' && pw.val() !== '';
}
if (fieldsPopulated() && !nu.is(':checked')) {
Meteor.loginWithPassword(un, pw, function(err) {
un.val('');
un.val('');
});
} else if (fieldsPopulated() && nu.is(':checked')) {
Accounts.createUser({
username: un.val(),
password: pw.val()
});
} else {
Meteor.loginWithPassword('', '', function(err) {
alert(err);
});
}
}
});
@joelip after completing the chapter I get this:
We can revisit later. Just making note here.