mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
If for some reason your user has no published fields, make sure Meteor.user()
still returns a (trivial) object.
This commit is contained in:
@@ -17,9 +17,13 @@
|
||||
var userId = Meteor.userId();
|
||||
if (!userId)
|
||||
return null;
|
||||
if (Meteor.userLoaded())
|
||||
return Meteor.users.findOne(userId);
|
||||
// Not yet loaded: return a minimal object.
|
||||
if (Meteor.userLoaded()) {
|
||||
var user = Meteor.users.findOne(userId);
|
||||
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};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user