bug 433936 r=jay Fix QAC login process

This commit is contained in:
ctalbert@mozilla.com 2008-05-16 09:59:37 -07:00
parent fd10479da8
commit 7f43c5d089
4 changed files with 52 additions and 5 deletions

View File

@ -176,7 +176,7 @@ var CC_loginManager = Components.classes["@mozilla.org/login-manager;1"];
// The LoginManager does not like "null" for username/password fields,
// So we send in the field names from the XUL.
var newLogin = new nsLoginInfo('chrome://qa', 'Litmus Login', litmus.baseURL,
var newLogin = new nsLoginInfo('chrome://qa', null, litmus.baseURL,
username, password, "username", "password");
try {
this.manager().addLogin(newLogin);
@ -187,7 +187,7 @@ var CC_loginManager = Components.classes["@mozilla.org/login-manager;1"];
getPasswordObj: function() {
try {
var logins = this.manager().findLogins({}, 'chrome://qa',
'Litmus Login', litmus.baseURL);
null, litmus.baseURL);
if (logins.length > 0 && logins[0] != null)
return logins[0];
return false;

View File

@ -47,6 +47,11 @@ var qaMain = {
window.open("chrome://qa/content/setup.xul", "_blank",
"chrome,all,dialog=yes");
}
else {
// We need to log the user into litmus
var storedLogin = qaPref.litmus.getPasswordObj();
this.correctCredentials(storedLogin.username, storedLogin.password, false);
}
if (qaPref.getPref(qaPref.prefBase + '.currentTestcase.testrunSummary', 'char') != null) {
litmus.readStateFromPref();
}
@ -68,6 +73,45 @@ var qaMain = {
}
qaPrefsWindow.lastSelectedTab = newSelection;
},
correctCredentials : function(username, password,isSecondTry) {
var callback = function (resp) {
if (resp.responseText == 0) {
qaMain.doLogin(isSecondTry);
} else {
// Then we need to store our validated creds
qaPref.litmus.setPassword(username, password);
}
}
// First we validate our stored login.
litmus.validateLogin(username, password, callback);
},
doLogin : function(isSecondTry) {
try {
var username = {value: "username"};
var password = {value: "password"};
var check = {value: "null"};
var title = qaMain.bundle.getString("qa.getpassword.title");
var msg = "";
if (!isSecondTry)
msg = qaMain.bundle.getString("qa.getpassword.message");
else
msg = qaMain.bundle.getString("qa.getpassword.tryagainmessage");
var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var result = prompts.promptUsernameAndPassword(null, title, msg, username,
password, null, check);
this.correctCredentials(username.value, password.value, true);
} catch(ex) {
alert("ERROR LOGGING IN: " + ex);
dump("Error logging in: " + ex);
}
}
};

View File

@ -42,4 +42,7 @@ qa.extension.prefs.savedMsg = Your settings have been saved
qa.extension.sysconfig.loadingMsg = Loading menu options...
qa.extension.loading = Loading...
qa.extension.litmus.progress = Now Testing %1$S of %2$S
qa.extension.litmus.stats = Tests Completed - Week: %1$S, Month: %2$S, All Time: %3$S
qa.extension.litmus.stats = Tests Completed - Week: %1$S, Month: %2$S, All Time: %3$S
qa.getpassword.title = Login to Litmus
qa.getpassword.message = Enter the login information for your Litmus Account
qa.getpassword.tryagainmessage = Incorrect login information. Please enter the email address and password for your Litmus Account, if you have forgotten it, ask on IRC in #qa to have it reset.

View File

@ -5,10 +5,10 @@
<RDF:Description RDF:about="rdf:#$QJqvE"
em:id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
em:minVersion="2.0"
em:maxVersion="3.0"/>
em:maxVersion="3.0.*"/>
<RDF:Description RDF:about="urn:mozilla:install-manifest"
em:id="{667e9f3d-0096-4d2b-b171-9a96afbabe20}"
em:version="0.1.12"
em:version="0.1.14"
em:type="2"
em:name="Mozilla QA Companion"
em:description="The QA tool for testers."