Bloc / meteor-chat-checkpoints

Ain't no party like a bloc chat party because a bloc chat party uses meteor to do cool stuff.
0 stars 1 forks source link

Error after user accounts chapter #12

Open mikesjewett opened 9 years ago

mikesjewett commented 9 years ago

@joelip after completing the chapter I get this:

Your app is crashing. Here's the latest log.

=> Errors prevented startup:

While building the application:
client/views/application/login_page.js:22:7: Unexpected token }

=> Your application has errors. Waiting for file change.

We can revisit later. Just making note here.

joelip commented 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);
      });
    }

  }
});