Meteor.loggingIn now true during the beginPasswordExchange part of

Meteor.loginWithPassword.
This commit is contained in:
David Glasser
2012-11-19 16:42:17 -08:00
parent 3b97c9199f
commit 738e8f43fa
2 changed files with 16 additions and 5 deletions

View File

@@ -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,

View File

@@ -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;