Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error after user accounts chapter #12

Open
mikesjewett opened this issue Sep 3, 2014 · 1 comment
Open

Error after user accounts chapter #12

mikesjewett opened this issue Sep 3, 2014 · 1 comment

Comments

@mikesjewett
Copy link
Contributor

@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
Copy link
Contributor

joelip commented Sep 3, 2014

@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);
      });
    }

  }
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants