0
votes

Anybody port user's accounts over to meteor using meteorImport? I have a json file filled with user data. It's a pretty straight forward data structure that imports into my Meteor.users collection just fine but while running autopublish and then logging the user data it appears to just disappear.

If I run db.users.find() in the mongodb terminal the data appears to be all there.

I've read that meteor makes a few fields available by default(username, emails, profile). So I've added these to my json file and the only thing I can get to log on the client side using Meteor.users.find().fetch() is the _Id.

returned from .find().fetch()

If I attempt to login using an email and password(it's been encoded) it says that the user is not found.

Template.manage.events({
    "click #submitLogin" : function(e, t){
      e.preventDefault();

      //http://blog.benmcmahen.com/post/41741539120/building-a-customized-accounts-ui-for-meteor

      var email = t.find("#username").value;
      var password = t.find("#password").value;

      //By default the server publishes username, emails,
      //and profile (writable by user).

      Meteor.loginWithPassword(email, password, function(err){
        if(err){

          alert(err);

        }else{
          alert("YOU ARE NOW LOGGED IN");
          Router.go("postLogin/teamMembersTable");
        }

      });
      return false;
    },
    "click #forgotPW": function(err){
      alert("CLICK ENCOUNTERED ON FORGOT PW" + err);
    }

What do you think I'm doing wrong while logging a user in that causes me to receive a user not found error? And most importantly... How do I fix this?

1
Odds are that you're missing the services key in your user collection which contains things like the encrypted (bcrypt) password. Create a Meteor user the normal way and compare its data with one of your imported users using meteor mongo on the server. - Michel Floyd

1 Answers

0
votes

By default I believe Meteor only publishes the 'profile' key data, unless you specifically publish user yourself, in which case it publishes everything, which is not what you want either.

so you need to publish on server:

Meteor.publish('users', function() {
    return Meteor.users.find({},{fields: {name:1, email:1 ...<-- the fields you want to publish here  }});
}) 

and on the client

Meteor.subscribe('users');

You also need permission rules to prevent the front end from modifying your collection:

Meteor.users.deny(
    {
        update: function () { return true; },
        remove: function () { return true; }
    }
);