2013-02-17 39 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){ 
相關問題