From 738e8f43faeec797dddce2fcd73a1f22cdb2351f Mon Sep 17 00:00:00 2001 From: David Glasser Date: Mon, 19 Nov 2012 16:42:17 -0800 Subject: [PATCH] Meteor.loggingIn now true during the beginPasswordExchange part of Meteor.loginWithPassword. --- packages/accounts-base/accounts_client.js | 15 ++++++++++----- packages/accounts-password/password_client.js | 6 ++++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/packages/accounts-base/accounts_client.js b/packages/accounts-base/accounts_client.js index 8b920f797f..91b126edbf 100644 --- a/packages/accounts-base/accounts_client.js +++ b/packages/accounts-base/accounts_client.js @@ -7,9 +7,14 @@ var loggingIn = false; var loggingInListeners = new Meteor.deps._ContextSet; - var setLoggingIn = function (x) { - loggingIn = x; - loggingInListeners.invalidateAll(); + // This is mostly just called within this file, but Meteor.loginWithPassword + // also uses it to make loggingIn() be true during the beginPasswordExchange + // method call too. + Accounts._setLoggingIn = function (x) { + if (loggingIn !== x) { + loggingIn = x; + loggingInListeners.invalidateAll(); + } }; Meteor.loggingIn = function () { loggingInListeners.addCurrentContext(); @@ -109,7 +114,7 @@ if (reconnected) return; - setLoggingIn(false); + Accounts._setLoggingIn(false); if (error || !result) { error = error || new Error( "No result from call to " + options.methodName); @@ -128,7 +133,7 @@ options.userCallback(); }; - setLoggingIn(true); + Accounts._setLoggingIn(true); Meteor.apply( options.methodName, options.methodArguments, diff --git a/packages/accounts-password/password_client.js b/packages/accounts-password/password_client.js index 8e0b7f2f17..0f9f8e8211 100644 --- a/packages/accounts-password/password_client.js +++ b/packages/accounts-password/password_client.js @@ -35,8 +35,14 @@ request.user = selector; + // Normally, we only set Meteor.loggingIn() to true within + // Accounts.callLoginMethod, but we'd also like it to be true during the + // password exchange. So we set it to true here, and clear it on error; in + // the non-error case, it gets cleared by callLoginMethod. + Accounts._setLoggingIn(true); Meteor.apply('beginPasswordExchange', [request], function (error, result) { if (error || !result) { + Accounts._setLoggingIn(false); error = error || new Error("No result from call to beginPasswordExchange"); callback && callback(error); return;