mirror of
https://github.com/bitwarden/mobile.git
synced 2024-11-21 11:25:56 +01:00
handle autofill for pages with no forms, but still has fields
This commit is contained in:
parent
5daeb0ee95
commit
4751cc04fc
@ -16,14 +16,14 @@ namespace Bit.iOS.Extension.Models
|
||||
|
||||
DocumentUUID = pageDetails.DocumentUUID;
|
||||
|
||||
var passwordFields = pageDetails.Fields.Where(f => f.Type == "password");
|
||||
var passwordForms = pageDetails.Forms.Where(form => passwordFields.Any(f => f.Form == form.Key));
|
||||
if(!passwordForms.Any())
|
||||
{
|
||||
return;
|
||||
}
|
||||
var passwordFields = pageDetails.Fields.Where(f => f.Type == "password").ToArray();
|
||||
var passwordForms = pageDetails.Forms.Where(form => passwordFields.Any(f => f.Form == form.Key)).ToArray();
|
||||
|
||||
PageDetails.Form loginForm = null;
|
||||
PageDetails.Field username = null, password = null;
|
||||
|
||||
if(passwordForms.Any())
|
||||
{
|
||||
if(passwordForms.Count() > 1)
|
||||
{
|
||||
// More than one form with a password field is on the page.
|
||||
@ -69,29 +69,41 @@ namespace Bit.iOS.Extension.Models
|
||||
loginForm = passwordForms.FirstOrDefault().Value;
|
||||
}
|
||||
|
||||
Script = new List<List<string>>();
|
||||
|
||||
var password = pageDetails.Fields.FirstOrDefault(f =>
|
||||
password = pageDetails.Fields.FirstOrDefault(f =>
|
||||
f.Form == loginForm.OpId
|
||||
&& f.Type == "password");
|
||||
|
||||
var username = pageDetails.Fields.LastOrDefault(f =>
|
||||
username = pageDetails.Fields.LastOrDefault(f =>
|
||||
f.Form == loginForm.OpId
|
||||
&& (f.Type == "text" || f.Type == "email")
|
||||
&& f.ElementNumber < password.ElementNumber);
|
||||
|
||||
if(loginForm.HtmlAction != null)
|
||||
{
|
||||
AutoSubmit = new Submit { FocusOpId = password.OpId };
|
||||
}
|
||||
}
|
||||
else if(passwordFields.Count() == 1)
|
||||
{
|
||||
password = passwordFields.First();
|
||||
if(password.ElementNumber > 0)
|
||||
{
|
||||
username = pageDetails.Fields[password.ElementNumber - 1];
|
||||
}
|
||||
}
|
||||
|
||||
Script = new List<List<string>>();
|
||||
|
||||
if(username != null)
|
||||
{
|
||||
Script.Add(new List<string> { "click_on_opid", username.OpId });
|
||||
Script.Add(new List<string> { "fill_by_opid", username.OpId, fillUsername });
|
||||
}
|
||||
|
||||
if(password != null)
|
||||
{
|
||||
Script.Add(new List<string> { "click_on_opid", password.OpId });
|
||||
Script.Add(new List<string> { "fill_by_opid", password.OpId, fillPassword });
|
||||
|
||||
if(loginForm.HtmlAction != null)
|
||||
{
|
||||
AutoSubmit = new Submit { FocusOpId = password.OpId };
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user