在`meteor Js`中创建用户方法错误?

时间:2014-03-18 05:40:57

标签: meteor

我是 meteor Js 的新手,我开发了流星应用程序以下错误是在服务器控制台中出现请验证我的代码并建议我如何解决错误。我是服务器JS和客户JS是我在哪里遇到的错误请验证并给我建议。

eRROR:
TypeError: Object #<Object> has no method 'createUser'
SERVER JS:
if (Meteor.isServer) 
{

  Meteor.startup(function () 
  {
    // code to run on server at startup
    if ( Meteor.users.find().count() === 0 )
      {
     Accounts.createUser
  ({
        username: 'admin',
        email: 'admin@hcare.com',
        password: '000000',
        profile: 
        {
            first_name: 'admin',
            last_name: 'admin',
            company: '3CubeTech',
        }
      }) //Added close parenthesis.
    }   
  });
}
cLIENT js:
Template.body.events
      ({
        'submit #login-form' : function (e,t)
     {
          /* template data, if any, is available in 'this'*/
          if (typeof console !== 'undefined')

        console.log("You pressed Login the button");
         e.preventDefault();
      /*retrieve the input field values*/
         var username = t.find('#username').value
         , password = t.find('#password').value;
          console.log(password);



       Meteor.loginWithPassword(username, password, function (err)
        {
        if (err) 
        {
          console.log(err);
          alert(err.reason);
          Session.set("loginError", true);
         }
         else
         {
        console.log(" Login Success ");
        console.log( ">>>>>>>>>>>>>>>>>>>>>>> userid="+Meteor.userId() ); 
        var adminUser =  Meteor.users.findOne({username:"admin"});
                console.log( ">>>>>>>>>>>>>>>>>>>>>>> adminUser()="+adminUser +" AND "+adminUser._id);  

         }
        });
        }
      });

1 个答案:

答案 0 :(得分:1)

运行mrt test-packages事实证明,我必须运行mrt add accounts-password