Skip to content

Commit

Permalink
page: fill 'other' inputs with standard field values, fix #547
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Vogt committed Dec 1, 2023
1 parent 7117a0a commit 4d44b5f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
5 changes: 4 additions & 1 deletion README.md
Expand Up @@ -87,7 +87,8 @@ credentials without password, but only login name.

Lines besides the login and URL that match the format `<other_inputfield_name>: <value>` can be used to fill in input
fields besides the login and password fields. The left hand side of the colon should match the input field's `name`,
`id`, `autocomplete`, or `placeholder` attribute.
`id`, `autocomplete`, or `placeholder` attribute. You can instruct PassFF to fill your login name, password, or
OTP token, by setting `<value>` to one of `PASSFF_FIELD_LOGIN`, `PASSFF_FIELD_PASSWORD`, or `PASSFF_FIELD_OTP`.

Examples
```
Expand All @@ -107,6 +108,8 @@ login: kevin
url: example.com
otpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&issuer=Example
pin: 1234
loginkey: PASSFF_FIELD_OTP
fancyinput: PASSFF_FIELD_LOGIN
```

##### File-structure format
Expand Down
16 changes: 12 additions & 4 deletions src/modules/page.js
Expand Up @@ -268,9 +268,9 @@ PassFF.Page = (function () {
// token, fill one digit from the token into each of the input fields.
let otp_inputs = inputs.filter((inp) => inp[1] == "otp");
let otp_filled = false;
if (otp_inputs.length == passwordData["otp"]?.length) {
passwordData["otp"].forEach((v, i) => {
writeValueWithEvents(otp_inputs[i], v);
if (otp_inputs.length == passwordData.otp?.length) {
otp_inputs.forEach((annotatedInput, i) => {
writeValueWithEvents(annotatedInput[0], passwordData.otp[i]);
})
otp_filled = true;
}
Expand All @@ -284,7 +284,15 @@ PassFF.Page = (function () {
let inputNames = readInputNames(input);
let matching = findIntersection(otherNames, inputNames);
if (matching !== undefined) {
writeValueWithEvents(input, passwordData._other[matching]);
let value = passwordData._other[matching];
if (value == "PASSFF_FIELD_OTP") {
value = passwordData.otp;
} else if (value == "PASSFF_FIELD_LOGIN") {
value = passwordData.login;
} else if (value == "PASSFF_FIELD_PASSWORD") {
value = passwordData.password;
}
writeValueWithEvents(input, value);
return;
}
}
Expand Down

0 comments on commit 4d44b5f

Please sign in to comment.