Bug 176348. Submit the correct form for autologin.
This commit is contained in:
parent
6494b45f59
commit
c973e3647c
@ -3,6 +3,8 @@
|
||||
|
||||
var bGlobalPrompt = 'true';
|
||||
var consoleService = null;
|
||||
var loginCounter = 0;
|
||||
var sAttemptedHost = '';
|
||||
|
||||
function logMessage(message)
|
||||
{
|
||||
@ -37,17 +39,19 @@ function websso()
|
||||
logMessage("Host URL not found");
|
||||
return;
|
||||
}
|
||||
|
||||
// reset loginprompt
|
||||
bGlobalPrompt = 'true';
|
||||
|
||||
var para=window._content.document.getElementsByTagName("input");
|
||||
var para=window._content.document.getElementsByTagName("input");
|
||||
|
||||
|
||||
for (var j = 0; !(j >= para.length) ; j++)
|
||||
{
|
||||
if((para.item(j).type == "password"))
|
||||
{
|
||||
ssosite = "yes";
|
||||
logMessage("Password field");
|
||||
logMessage(para.item(j).name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -102,7 +106,7 @@ function websso()
|
||||
}
|
||||
|
||||
|
||||
|
||||
var formToSubmit;
|
||||
|
||||
// looping for inputs and setting the correct values
|
||||
for (var j = 0; !(j >= para.length) ; j++)
|
||||
@ -110,8 +114,7 @@ function websso()
|
||||
try
|
||||
{
|
||||
if((para.item(j).type == "text") || (para.item(j).type == "password"))
|
||||
{
|
||||
//alert(test);
|
||||
{
|
||||
sKey = para.item(j).name;
|
||||
logMessage('Getting: ' + secretId + ':' + sKey);
|
||||
|
||||
@ -126,6 +129,20 @@ function websso()
|
||||
ele[0].value = theValue.value;
|
||||
}
|
||||
}
|
||||
|
||||
// locate and save off the form of the password element
|
||||
if (para.item(j).type == "password")
|
||||
{
|
||||
formToSubmit = para.item(j).parentNode.parentNode;
|
||||
|
||||
// did we get it?
|
||||
if (formToSubmit.type != "form")
|
||||
{
|
||||
formToSubmit = formToSubmit.parentNode;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch (err)
|
||||
@ -140,14 +157,41 @@ function websso()
|
||||
res = obj.miCASAReadKey(secretId, 'autologin', theValue);
|
||||
if (theValue.value == 'true')
|
||||
{
|
||||
logMessage('Autologin begins');
|
||||
window._content.document.forms[0].submit();
|
||||
// if this is a new url, reset the counter
|
||||
if (sAttemptedHost != url)
|
||||
{
|
||||
loginCounter = 0;
|
||||
}
|
||||
|
||||
// if we've attempted this login before, don't try it again
|
||||
if (loginCounter > 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// if there's more than one form, determine which one to submit.
|
||||
var forms = window._content.document.forms;
|
||||
if (forms.length > 1)
|
||||
{
|
||||
// find the form with the matching password id.
|
||||
logMessage("More than 1 form on page");
|
||||
}
|
||||
else
|
||||
{
|
||||
formToSubmit = window._content.document.forms[0].submit();
|
||||
}
|
||||
|
||||
//try it now
|
||||
logMessage('Autologin begins');
|
||||
sAttemptedHost = url;
|
||||
loginCounter += 1;
|
||||
|
||||
formToSubmit.submit();
|
||||
}
|
||||
}
|
||||
catch (err1)
|
||||
{
|
||||
|
||||
|
||||
logMessage(err1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -159,7 +203,7 @@ function promptuser()
|
||||
var password = "";
|
||||
var bIsLogin = 'false';
|
||||
var sPromptURL = "chrome://casa/content/prompt.xul?";
|
||||
var ele=window._content.document.getElementsByTagName("input");
|
||||
var ele=window._content.document.getElementsByTagName("input");
|
||||
var secretID = window._content.location.host;
|
||||
|
||||
if (bGlobalPrompt != 'true')
|
||||
@ -177,7 +221,7 @@ function promptuser()
|
||||
{
|
||||
bIsLogin = 'true';
|
||||
password = ele.item(i).value;
|
||||
sPromptURL = sPromptURL + "&" + ele.item(i).name + "=" + ele.item(i).value;
|
||||
sPromptURL = sPromptURL + "&" + ele.item(i).name + "=" + ele.item(i).value;
|
||||
|
||||
// don't prompt user if password field is the same
|
||||
try
|
||||
@ -228,7 +272,7 @@ function promptuser()
|
||||
}
|
||||
|
||||
if (bIsLogin == 'true')
|
||||
{
|
||||
{
|
||||
//if (confirm("Save credentials in CASA?"))
|
||||
{
|
||||
var properties = "modal=yes,status=no,titlebar=no,toolbar=no,menubar=no,location=no,height=100,width=100";
|
||||
|
Loading…
Reference in New Issue
Block a user