2013-02-17 14 views
5

Jestem w stanie zarejestrować użytkownika wysyłającego e-mail i zobaczyć go w Meteor.users do tej pory, który działa ... Po wylogowaniu i próbie zalogowania się ' m otrzymuję błądOtrzymuję komunikat o błędzie podczas logowania się w Meteor.loginWithPassword

jest to błąd dostaję: Meteor.Error {błąd: 403, powód: „nie znaleziono użytkownika”, szczegóły: niezdefiniowana}

W moim konsoli jeśli to zrobię: Meteor.users

widzę użytkownikowi tam: a46e6e5a-03dd-4bef-9ea7-eb08ba6c2cd9: Przedmiot _id: "A46e6e5a-03dd-4bef-9ea7-eb08ba6c2cd9" nazwa: "[email protected]" proto: Przedmiot

Oto mój kod:

if (Meteor.isClient) { 


    Template.landing.events({ 
    'click #login-btn' : function() { 
     var username = $('#input-email').val(); 
     var password = $('#input-password').val(); 
     console.log(username); 
     Meteor.loginWithPassword(username, password, function(err){ 
     if (err) { 
      console.log(err); 
     }; 
     }); 
    }, 
    'click #invite-btn' : function() { 
     //console.log("You pressed the button"); 
     //open a modal window with sign up and create account ui 
    }, 
    'click #signup-btn' : function() { 
     //console.log("You pressed the signup-btn"); 

     var options = { 
      username: $('#input-email').val(), 
      password: $('#input-password').val() 
     }; 

     Accounts.createUser(options, function(err){ 
     //$('#inputs').addClass('error') 
     //console.log($('#inputs')) 
     if (err) { 

      console.log(err); 

     }else{ 
      $('#myModal').modal('hide'); 
      // In your client code: asynchronously send an email 
      Meteor.call('sendEmail', 
         $('#input-email').val(), 
         '[email protected]', 
         'Thanks for requesting a invite code', 
         'We are glad you signed up for a invite to SlideSlider. We are working to get our closed bate up and running. Please stay tuned.'); 
     } 
     }); 

    } 
    }); 



    Template.loggedin.events({ 
    'click #logout-btn' : function() { 
     Meteor.logout(); 
    } 
    }); 


} 

if (Meteor.isServer) { 

    Meteor.methods({ 
    sendEmail: function (to, from, subject, text) { 
     // Let other method calls from the same client start running, 
     // without waiting for the email sending to complete. 
     this.unblock(); 
     console.log("send email"); 
     Email.send({ 
     to: to, 
     from: from, 
     subject: subject, 
     text: text 
     }); 
    } 
    }); 

} 

Każda pomoc będzie niesamowite, btw to mój pierwszy stackoverflow pytanie :)

+11

Ok poprawka wydaje się być na linii 11: Meteor.loginWithPassword (nazwa użytkownika, hasło, funkcja (err) {powinno być: Meteor.loginWithPassword ({nazwa użytkownika: nazwa użytkownika} hasło, funkcja (err) { – Justin

+1

może możesz zrobić niż odpowiedź na własne pytanie. –

+0

@Justin Powinieneś dodać jako odpowiedź, ponieważ to również rozwiązało mój problem –

Odpowiedz

-1

Jak Justin nie dodać swoją odpowiedź, będę skopiować swój komentarz i dodaj go tutaj:
Rozwiązaniem wydaje się być na linii 11:

Meteor.loginWithPassword(username, password, function(err){ 

powinno być:

Meteor.loginWithPassword({username:username}, password, function(err){ 
Powiązane problemy