From 98111eb6c9c5341173ff61dec06c0253179b3288 Mon Sep 17 00:00:00 2001 From: David Glasser Date: Wed, 10 Oct 2012 21:41:47 -0700 Subject: [PATCH] If for some reason your user has no published fields, make sure Meteor.user() still returns a (trivial) object. --- packages/accounts-base/accounts_client.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/accounts-base/accounts_client.js b/packages/accounts-base/accounts_client.js index 0a50eba3d8..796efc1b2f 100644 --- a/packages/accounts-base/accounts_client.js +++ b/packages/accounts-base/accounts_client.js @@ -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}; };