5

到目前为止,我可以注册一个用户发送电子邮件并在 Meteor.users 中看到他……在我注销并尝试登录后,我收到了一个错误

这是我得到的错误: Meteor.Error {error: 403, reason: "User not found", details: undefined}

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

我在那里看到我的用户:a46e6e5a-03dd-4bef-9ea7-eb08ba6c2cd9:对象_id:“a46e6e5a-03dd-4bef-9ea7-eb08ba6c2cd9”用户名:“myemail@gmail.com” 原型:对象

这是我的代码:

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(),
                      'update@mydomain.com',
                      '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
      });
    }
  });

}

任何帮助都会很棒,顺便说一句,这是我的第一个 stackoverflow 问题:)

4

0 回答 0