diff options
Diffstat (limited to 'lib/libbugzilla.js')
-rw-r--r-- | lib/libbugzilla.js | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/libbugzilla.js b/lib/libbugzilla.js index d03cd3c..f7ae37b 100644 --- a/lib/libbugzilla.js +++ b/lib/libbugzilla.js @@ -294,16 +294,19 @@ exports.createUpstreamBug = function createUpstreamBug(urlStr, subjectStr, comme }; function loginToAllBugzillas(callback) { - var callbacksCounter = 0, bugzilla = ""; + var loginCallsCounter = 0, bugzilla = ""; if ("enabledPackages" in config.gJSONData.configData) { + // For all bugzillas we are interested in ... for (bugzillaHost in config.gJSONData.configData.enabledPackages) { passUtils.search({ url: "https://" + bugzillaHost, realm: BTSPassRealm, + // ... and for which we have credentials on file ... onComplete: function onComplete(credentials) { + // (we can have more than one set of credentials per bugzilla; + // well, theoretically) credentials.forEach(function(credential) { - debug("credential = " + credential.toSource()); - // function makeJSONRPCCall(url, method, params, callback) + // ... login! makeJSONRPCCall(credential.url + "/jsonrpc.cgi", "User.login", { login: credential.username, @@ -311,13 +314,15 @@ function loginToAllBugzillas(callback) { remember: false }, function(logResult) { debug("Logging as " + credential.username + " to " + credential.url); - callbacksCounter--; - if (callbacksCounter <= 0) { + loginCallsCounter--; + // When we complete all logins, execute the callback + if (loginCallsCounter <= 0) { debug("All logins done!"); callback(); } }); - callbacksCounter++; + // Increment call counter + loginCallsCounter++; }); }, onError: function onError() { |