1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-21 18:53:29 +00:00

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

View File

@@ -85,12 +85,22 @@ namespace Bit.iOS.Extension.Models
} }
else if(passwordFields.Count() == 1) 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(); password = passwordFields.First();
if(password.ElementNumber > 0) if(password.ElementNumber > 0)
{
username = pageDetails.Fields.LastOrDefault(f =>
(f.Type == "text" || f.Type == "email")
&& f.ElementNumber < password.ElementNumber);
if(username == null)
{ {
username = pageDetails.Fields[password.ElementNumber - 1]; username = pageDetails.Fields[password.ElementNumber - 1];
} }
} }
}
Script = new List<List<string>>(); Script = new List<List<string>>();