1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-27 12:36:14 +01:00

fields are for all types

This commit is contained in:
Kyle Spearrin 2017-10-17 21:35:27 -04:00
parent 0e692d8c86
commit 3d45cfc7b8

View File

@ -167,7 +167,7 @@ function initAutofill() {
}; };
function generateFillScript(self, pageDetails, options) { function generateFillScript(self, pageDetails, options) {
if (!pageDetails) { if (!pageDetails || !options.cipher) {
return null; return null;
} }
@ -180,37 +180,9 @@ function initAutofill() {
metadata: {} metadata: {}
}; };
switch (options.cipher.type) { var filledFields = {},
case self.constantsService.cipherType.login:
fillScript = generateLoginFillScript(fillScript, pageDetails, options);
break;
case self.constantsService.cipherType.card:
fillScript = generateLoginFillScript(fillScript, pageDetails, options);
break;
case self.constantsService.cipherType.identity:
fillScript = generateLoginFillScript(fillScript, pageDetails, options);
break;
default:
return null;
}
return fillScript;
}
function generateLoginFillScript(fillScript, pageDetails, options) {
if (!options.cipher.login) {
return null;
}
var passwordFields = [],
passwords = [],
usernames = [],
filledFields = {},
pf = null,
username = null,
i = 0, i = 0,
fields = options.cipher.fields, fields = options.cipher.fields;
login = options.cipher.login;
if (fields && fields.length) { if (fields && fields.length) {
var fieldNames = []; var fieldNames = [];
@ -239,6 +211,36 @@ function initAutofill() {
} }
} }
switch (options.cipher.type) {
case self.constantsService.cipherType.login:
fillScript = generateLoginFillScript(fillScript, pageDetails, filledFields, options);
break;
case self.constantsService.cipherType.card:
fillScript = generateLoginFillScript(fillScript, pageDetails, filledFields, options);
break;
case self.constantsService.cipherType.identity:
fillScript = generateLoginFillScript(fillScript, pageDetails, filledFields, options);
break;
default:
return null;
}
return fillScript;
}
function generateLoginFillScript(fillScript, pageDetails, filledFields, options) {
if (!options.cipher.login) {
return null;
}
var passwordFields = [],
passwords = [],
usernames = [],
pf = null,
username = null,
i = 0,
login = options.cipher.login;
if (!login.password || login.password === '') { if (!login.password || login.password === '') {
// No password for this login. Maybe they just wanted to auto-fill some custom fields? // No password for this login. Maybe they just wanted to auto-fill some custom fields?
fillScript = setFillScriptForFocus(filledFields, fillScript); fillScript = setFillScriptForFocus(filledFields, fillScript);
@ -334,7 +336,7 @@ function initAutofill() {
return fillScript; return fillScript;
} }
function generateCardFillScript(fillScript, pageDetails, options) { function generateCardFillScript(fillScript, pageDetails, filledFields, options) {
if (!options.cipher.card) { if (!options.cipher.card) {
return null; return null;
} }
@ -342,7 +344,7 @@ function initAutofill() {
var card = options.cipher.card; var card = options.cipher.card;
} }
function generateIdentityFillScript(fillScript, pageDetails, options) { function generateIdentityFillScript(fillScript, pageDetails, filledFields, options) {
if (!options.cipher.identity) { if (!options.cipher.identity) {
return null; return null;
} }