docs: function (err, result) {
      if (err || !result || !result.token) {
        Accounts.connection.onReconnect = null;
      } else {
        Accounts.connection.onReconnect = function () {
          reconnected = true;
          // If our token was updated in storage, use the latest one.
          var storedToken = storedLoginToken();
          if (storedToken) {
            result = {
              token: storedToken,
              tokenExpires: storedLoginTokenExpires()
            };
          }
          if (! result.tokenExpires)
            result.tokenExpires = Accounts._tokenExpiration(new Date());
          if (Accounts._tokenExpiresSoon(result.tokenExpires)) {
            makeClientLoggedOut();
          } else {
            Accounts.callLoginMethod({
              methodArguments: [{resume: result.token}],
              // Reconnect quiescence ensures that the user doesn't see an
              // intermediate state before the login method finishes. So we don't
              // need to show a logging-in animation.
              _suppressLoggingIn: true,
              userCallback: function (error) {
                var storedTokenNow = storedLoginToken();
                if (error) {
                  // If we had a login error AND the current stored token is the
                  // one that we tried to log in with, then declare ourselves
                  // logged out. If there's a token in storage but it's not the
                  // token that we tried to log in with, we don't know anything
                  // about whether that token is valid or not, so do nothing. The
                  // periodic localStorage poll will decide if we are logged in or
                  // out with this token, if it hasn't already. Of course, even
                  // with this check, another tab could insert a new valid token
                  // immediately before we clear localStorage here, which would
                  // lead to both tabs being logged out, but by checking the token
                  // in storage right now we hope to make that unlikely to happen.
                  //
                  // If there is no token in storage right now, we don't have to
                  // do anything; whatever code removed the token from storage was
                  // responsible for calling `makeClientLoggedOut()`, or the
                  // periodic localStorage poll will call `makeClientLoggedOut`
                  // eventually if another tab wiped the token from storage.
                  if (storedTokenNow && storedTokenNow === result.token) {
                    makeClientLoggedOut();
                  }
                }
                // Possibly a weird callback to call, but better than nothing if
                // there is a reconnect between "login result received" and "data
                // ready".
                onceUserCallback(error);
              }});
          }
        };
      }
    }