2013-02-17 90 views
5

我能够注册用户发送电子邮件并在Meteor.users中查看他的作品...在我注销并尝试登录后, m如果一个错误我在使用Meteor.loginWithPassword登录时遇到错误

这是我得到的错误: Meteor.Error {错误:403,原因是:“用户未找到”,详细信息:未定义}

在我的控制台如果我这样做: Meteor.users

我看到我的用户在那里: a46e6e5a-03dd-4bef-9ea7-eb08ba6c2cd9:Object _id: “a46e6e5a-03dd-4bef-9ea7-eb08ba6c2cd9” 用户名: “[email protected]:对象

这里是我的代码:

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

} 

任何帮助将是真棒,顺便说一句这是我的第一个计算器问题:)

+11

确定修复似乎是第11行:Meteor.loginWithPassword(用户名,密码,功能(ERR){应该是:Meteor.loginWithPassword({用户名:用户名},密码,功能(错误){ – Justin 2013-02-17 16:20:55

+1

也许你可以做出比你自己的问题的答案。 – 2016-02-28 07:12:30

+0

@Justin你应该添加作为你的答案,因为它也解决了我的问题 – 2016-10-19 19:22:22

回答

-1

贾斯汀没加他的回答,我会复制他的意见,并在此添加:
的修复似乎是第11行:

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

应该是:

Meteor.loginWithPassword({username:username}, password, function(err){ 
相关问题