If for some reason your user has no published fields, make sure Meteor.user()

still returns a (trivial) object.
This commit is contained in:
David Glasser
2012-10-10 21:41:47 -07:00
parent 2c6f991228
commit 98111eb6c9

View File

@@ -17,9 +17,13 @@
var userId = Meteor.userId(); var userId = Meteor.userId();
if (!userId) if (!userId)
return null; return null;
if (Meteor.userLoaded()) if (Meteor.userLoaded()) {
return Meteor.users.findOne(userId); var user = Meteor.users.findOne(userId);
// Not yet loaded: return a minimal object. if (user) return user;
}
// Either the subscription isn't done yet, or for some reason this user has
// no published fields (and thus is considered to not exist in
// minimongo). Return a minimal object.
return {_id: userId}; return {_id: userId};
}; };