2013-02-17 27 views
5

Tôi có thể đăng ký người dùng gửi email và xem anh ấy trong Meteor.users cho đến nay hoạt động ... Sau khi tôi đăng xuất và thử đăng nhập I ' m nhận được một lỗiTôi gặp lỗi khi đăng nhập bằng Meteor.loginWithPassword

Đây là lỗi tôi nhận được: Meteor.Error {error: 403, lý do: "người dùng không tìm thấy", cụ thể: không xác định}

Trong giao diện điều khiển của tôi nếu tôi làm: Meteor.users

Tôi thấy người dùng của mình ở đó: a46e6e5a-03dd-4bef-9ea7-eb08ba6c2cd9: Đối tượng _id: "A46e6e5a-03dd-4bef-9ea7-eb08ba6c2cd9" username: "[email protected]" proto: Object

Đây là mã của tôi:

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

} 

Bất kỳ trợ giúp sẽ là tuyệt vời, btw đây là lần đầu tiên câu hỏi stackoverflow tôi :)

+11

Ok việc sửa chữa có vẻ là trên dòng 11: Meteor.loginWithPassword (username, password, function (err) {nên là: Meteor.loginWithPassword ({username: username}, mật khẩu, chức năng (err) { – Justin

+1

có thể bạn có thể làm hơn là câu trả lời cho câu hỏi của riêng bạn. –

+0

@Justin Bạn nên thêm làm câu trả lời, vì nó cũng giải quyết được vấn đề của tôi –

Trả lời

-1

Như Justin đã không thêm câu trả lời của mình, tôi sẽ sao chép bình luận của mình và thêm nó ở đây:
Việc sửa chữa có vẻ là trên dòng 11:

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

nên là:

Meteor.loginWithPassword({username:username}, password, function(err){ 
Các vấn đề liên quan