aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2012-04-11 02:41:20 +0200
committerMatěj Cepl <mcepl@redhat.com>2012-04-11 02:45:19 +0200
commitdd0b43442c1642eb6db6fb6a7711eefe7a1119ef (patch)
treec73ca419ea329ee2fb2e87faf2872a938de90849
parentba9bd8b38bb04421dbc4fa045b02a6f320d817d6 (diff)
downloadbugzilla-triage-dd0b43442c1642eb6db6fb6a7711eefe7a1119ef.tar.gz
Make the script bugs.eclipse.org compatible.
Closes #120
-rw-r--r--data/lib/bugzillaDOMFunctions.js7
-rw-r--r--data/lib/bzpage.js2
-rw-r--r--data/tweaks/bug-page-mod.js4
-rw-r--r--lib/libbugzilla.js96
4 files changed, 55 insertions, 54 deletions
diff --git a/data/lib/bugzillaDOMFunctions.js b/data/lib/bugzillaDOMFunctions.js
index 5c9423e..be30a3e 100644
--- a/data/lib/bugzillaDOMFunctions.js
+++ b/data/lib/bugzillaDOMFunctions.js
@@ -356,17 +356,14 @@ function getAttachments () {
* @return String with the login name of the currently logged-in user
*/
function getLogin () {
- var lastElemArr = "";
+ var lastElemArr = [];
var LIElementsArr = document.querySelectorAll("#header ul.links li");
// This should never be null
- console.log("LIElementsArr = " + LIElementsArr);
if (LIElementsArr.length > 0) {
- lastElemArr = Array.filter(LIElementsArr, function(el) {
- console.log("el = " + el.toSource());
+ lastElemArr = Array.filter(LIElementsArr, function(el, idx, arr) {
return (el.textContent.indexOf("Log") !== -1);
});
}
- console.log("lastElemArr = " + lastElemArr.toSource());
var lastLIElement = "";
if (lastElemArr) {
lastLIElement = lastElemArr.pop();
diff --git a/data/lib/bzpage.js b/data/lib/bzpage.js
index 8d7606f..e44f3f4 100644
--- a/data/lib/bzpage.js
+++ b/data/lib/bzpage.js
@@ -408,7 +408,7 @@ function startup() {
self.postMessage(new Message("GetInstalledPackages", {
location: window.location.href,
- login: getLogin()
+ login: getLogin(),
}));
}
}
diff --git a/data/tweaks/bug-page-mod.js b/data/tweaks/bug-page-mod.js
index 32672b0..d3551a3 100644
--- a/data/tweaks/bug-page-mod.js
+++ b/data/tweaks/bug-page-mod.js
@@ -170,7 +170,9 @@ function tweakBugzilla(things, cData) {
var CheckinComment = new CheckinCommentCtor();
CheckinComment.initialize(AttachmentFlagHandler._interestingFlags);
- collectHistory();
+ if (!cData.passwordState.withoutPass) {
+ collectHistory();
+ }
tbplbotSpamCollapser();
}
diff --git a/lib/libbugzilla.js b/lib/libbugzilla.js
index e5d6e25..acb81e8 100644
--- a/lib/libbugzilla.js
+++ b/lib/libbugzilla.js
@@ -87,69 +87,70 @@ function getPassword(login, domain, callback) {
"for accessing JSONRPC services";
var switchPrompt = "Do you want to switch off XML-RPC " +
"for domain ";
- var prefName = BTSPrefNS + "withoutPassowrd", prefValue = [];
+ var prefName = BTSPrefNS + "withoutPassword", prefValue = [];
var retObject = {
password: null, // password string or null if no password provided
withoutPass: [] // whether user doesn't want to use password at all
};
if (preferences.has(prefName)) {
- prefValue = JSON.parse(preferences.get(prefName, null));
- debug("getPassword: prefValue = " + prefValue);
- if ((prefValue === true) || (prefValue === false)) {
- console.log("Clearing previous scheme of " + prefName +
- " preference " + prefValue + ".");
- preferences.set(prefName, JSON.stringify([]));
- prefValue = [];
- }
+ prefValue = JSON.parse(preferences.get(prefName, []));
+ debug("getPassword: prefValue = " + prefValue.toSource());
}
- if (prefValue.indexOf(domain) == -1) {
- passUtils.search({
- username: login,
- url: domain,
- realm: BTSPassRealm,
- onComplete: function onComplete(credList) {
+ // First try to find the password in the password manager
+ passUtils.search({
+ username: login,
+ url: domain,
+ realm: BTSPassRealm,
+ onComplete: function onComplete(credList) {
+ console.log("found credList = " + credList);
var credential = [];
if (credList) {
- credential = credList[0];
+ credential = credList[0];
}
- if (credential) {
- // We found the password, just go ahead and use it
- retObject.password = credential.password;
- callback(retObject);
+ if (credential) {
+ // We found the password, just go ahead and use it
+ retObject.password = credential.password;
+ callback(retObject);
+ }
+ // If we don't have a password, is the domain forbidden?
+ // Don't use isInList ... we don't have it here.
+ else if (prefValue.indexOf(domain) == -1) {
+ debug("Domain " + domain + " is not forbidden!");
+ // We don't have a stored password, ask for one
+ var passwordText = prompts.promptPassword(passPrompt);
+ if (passwordText && passwordText.length > 0) {
+ // Right, we've got it … store it and then use it.
+ retObject.password = passwordText;
+ passUtils.store({
+ username: login,
+ password: passwordText,
+ url: domain,
+ realm: BTSPassRealm,
+ onComplete: function onComplete() {
+ callback(retObject);
+ }
+ });
}
else {
- // We don't have a stored password, ask for one
- var passwordText = prompts.promptPassword(passPrompt);
- if (passwordText && passwordText.length > 0) {
- // Right, we've got it … store it and then use it.
- retObject.password = passwordText;
- passUtils.store({
- username: login,
- password: passwordText,
- url: domain,
- realm: BTSPassRealm,
- onComplete: function onComplete() {
- callback(retObject);
- }
- });
- }
- else {
- // We don't have password, and user haven't entered one?
- // Does he want to live passwordless for this domain?
- var switchOff = prompts.promptYesNoCancel(switchPrompt + domain + "?");
- if (switchOff) {
- prefValue.push(domain);
- preferences.set(prefName, JSON.stringify(prefValue));
- }
- retObject.withoutPass = prefValue;
- callback(retObject);
+ // We don't have password, and user haven't entered one?
+ // Does he want to live passwordless for this domain?
+ var switchOff = prompts.promptYesNoCancel(switchPrompt + domain + "?");
+ if (switchOff) {
+ prefValue.push(domain);
+ preferences.set(prefName, JSON.stringify(prefValue));
}
+ retObject.withoutPass = prefValue;
+ callback(retObject);
}
}
- });
- }
+ else {
+ debug("Domain " + domain + " is forbidden!");
+ callback(retObject);
+ }
+ } // onComplete
+ });
}
// Change URL of the configuration JSON file
@@ -337,6 +338,7 @@ function loginToAllBugzillas(callback) {
debug("logResult = " + logResult.toSource());
loginCallsCounter--;
debug("after decrease loginCallsCounter = " + loginCallsCounter);
+ debug("Logged as " + credential.username + " to " + credential.url);
// When we complete all logins, execute the callback
if (loginCallsCounter <= 0) {
debug("All logins done!");