Give a chance to fields with type other than text and email to be a username (improve website compatibility)
This commit is contained in:
parent
b255a8cd90
commit
075dd914f1
|
@ -265,6 +265,48 @@ function wildcard_domain(domain)
|
|||
return "";
|
||||
}
|
||||
|
||||
function _add_name(logins, name)
|
||||
{
|
||||
for(var i=0; i<logins.length; i++)
|
||||
if (logins[i] == name) return ;
|
||||
logins.push(name);
|
||||
}
|
||||
|
||||
function try_get_name(fields, type_filters, match)
|
||||
{
|
||||
var user = null;
|
||||
var all_logins = new Array();
|
||||
|
||||
for (var i=0; i<fields.length; i++)
|
||||
{
|
||||
var field = fields[i];
|
||||
|
||||
for (var a=0; a<type_filters.length; a++)
|
||||
{
|
||||
if ((match && field.getAttribute("type") == type_filters[a]) ||
|
||||
(!match && field.getAttribute("type") != type_filters[a]))
|
||||
{
|
||||
if (field.hasAttribute("name") && field.value != "")
|
||||
{
|
||||
name = field.getAttribute("name");
|
||||
// Subset of common user field
|
||||
if (name == "user") user = field.value;
|
||||
else if (name == "usr") user = field.value;
|
||||
else if (name == "username") user = field.value;
|
||||
else if (name == "login") user = field.value;
|
||||
|
||||
_add_name(all_logins, field.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (user != null)
|
||||
return new Array(user);
|
||||
else
|
||||
return all_logins;
|
||||
}
|
||||
|
||||
function on_sumbit(e)
|
||||
{
|
||||
var form = this;
|
||||
|
@ -279,32 +321,18 @@ function on_sumbit(e)
|
|||
|
||||
debug("salt " + salt);
|
||||
|
||||
var user = null;
|
||||
var all_logins = new Array();
|
||||
|
||||
type_filters = new Array();
|
||||
// Get all <input type="text"> && <input type="email">
|
||||
for (var i=0; i<fields.length; i++)
|
||||
{
|
||||
var field = fields[i];
|
||||
if (field.getAttribute("type") == "text" || field.getAttribute("type") == "email")
|
||||
{
|
||||
if (field.hasAttribute("name") && field.value != "")
|
||||
{
|
||||
name = field.getAttribute("name");
|
||||
// Subset of common user field
|
||||
if (name == "user") user = field.value;
|
||||
else if (name == "usr") user = field.value;
|
||||
else if (name == "username") user = field.value;
|
||||
else if (name == "login") user = field.value;
|
||||
all_logins.push(field.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
type_filters.push("text");
|
||||
type_filters.push("email");
|
||||
logins = try_get_name(fields, type_filters, true);
|
||||
|
||||
if (user != null)
|
||||
logins = new Array(user);
|
||||
else
|
||||
logins = all_logins;
|
||||
// Get all other fields except text, email and password
|
||||
if (!logins.length)
|
||||
{
|
||||
type_filters.push("password");
|
||||
logins = try_get_name(fields, type_filters, false);
|
||||
}
|
||||
|
||||
// Look for <input type="password" value="@@...">
|
||||
for (var i=0; i<fields.length; i++)
|
||||
|
|
|
@ -272,6 +272,48 @@ function wildcard_domain(domain)
|
|||
return "";
|
||||
}
|
||||
|
||||
function _add_name(logins, name)
|
||||
{
|
||||
for(var i=0; i<logins.length; i++)
|
||||
if (logins[i] == name) return ;
|
||||
logins.push(name);
|
||||
}
|
||||
|
||||
function try_get_name(fields, type_filters, match)
|
||||
{
|
||||
var user = null;
|
||||
var all_logins = new Array();
|
||||
|
||||
for (var i=0; i<fields.length; i++)
|
||||
{
|
||||
var field = fields[i];
|
||||
|
||||
for (var a=0; a<type_filters.length; a++)
|
||||
{
|
||||
if ((match && field.getAttribute("type") == type_filters[a]) ||
|
||||
(!match && field.getAttribute("type") != type_filters[a]))
|
||||
{
|
||||
if (field.hasAttribute("name") && field.value != "")
|
||||
{
|
||||
name = field.getAttribute("name");
|
||||
// Subset of common user field
|
||||
if (name == "user") user = field.value;
|
||||
else if (name == "usr") user = field.value;
|
||||
else if (name == "username") user = field.value;
|
||||
else if (name == "login") user = field.value;
|
||||
|
||||
_add_name(all_logins, field.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (user != null)
|
||||
return new Array(user);
|
||||
else
|
||||
return all_logins;
|
||||
}
|
||||
|
||||
function on_sumbit(e)
|
||||
{
|
||||
var form = this;
|
||||
|
@ -286,32 +328,18 @@ function on_sumbit(e)
|
|||
|
||||
debug("salt " + salt);
|
||||
|
||||
var user = null;
|
||||
var all_logins = new Array();
|
||||
|
||||
type_filters = new Array();
|
||||
// Get all <input type="text"> && <input type="email">
|
||||
for (var i=0; i<fields.length; i++)
|
||||
{
|
||||
var field = fields[i];
|
||||
if (field.getAttribute("type") == "text" || field.getAttribute("type") == "email")
|
||||
{
|
||||
if (field.hasAttribute("name") && field.value != "")
|
||||
{
|
||||
name = field.getAttribute("name");
|
||||
// Subset of common user field
|
||||
if (name == "user") user = field.value;
|
||||
else if (name == "usr") user = field.value;
|
||||
else if (name == "username") user = field.value;
|
||||
else if (name == "login") user = field.value;
|
||||
all_logins.push(field.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
type_filters.push("text");
|
||||
type_filters.push("email");
|
||||
logins = try_get_name(fields, type_filters, true);
|
||||
|
||||
if (user != null)
|
||||
logins = new Array(user);
|
||||
else
|
||||
logins = all_logins;
|
||||
// Get all other fields except text, email and password
|
||||
if (!logins.length)
|
||||
{
|
||||
type_filters.push("password");
|
||||
logins = try_get_name(fields, type_filters, false);
|
||||
}
|
||||
|
||||
// Look for <input type="password" value="@@...">
|
||||
for (var i=0; i<fields.length; i++)
|
||||
|
|
Loading…
Reference in New Issue
Block a user