smarter username field selection for no form condition

This commit is contained in:
Kyle Spearrin 2016-09-17 13:47:14 -04:00
parent 4751cc04fc
commit 2a44937d09
1 changed files with 11 additions and 1 deletions

View File

@ -85,10 +85,20 @@ namespace Bit.iOS.Extension.Models
}
else if(passwordFields.Count() == 1)
{
// The page does not have any forms with password fields. Use the one password field on the page and the
// input field just before it as the username.
password = passwordFields.First();
if(password.ElementNumber > 0)
{
username = pageDetails.Fields[password.ElementNumber - 1];
username = pageDetails.Fields.LastOrDefault(f =>
(f.Type == "text" || f.Type == "email")
&& f.ElementNumber < password.ElementNumber);
if(username == null)
{
username = pageDetails.Fields[password.ElementNumber - 1];
}
}
}