1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-09-14 02:08:50 +02:00

Fix for issue #1287 in bitwarden/web (#569)

* Format the fieldvalue as a LocaleDateString instead of epoch when importing a date from 1P

This would be better solved by storing it as a date FieldType instead of Text. But since it is unclear when new field types are added, this solution serves as a fix for now and also guides the solution when new fieldtype exists.

* Remove trailing whitespace

* Add tests for custom fields of 1pif imported identity

* Change representation of 1pif imported dates to UTC string

* Changes after running prettier

Co-authored-by: Daniel James Smith <djsmith@web.de>
This commit is contained in:
Linus Aarnio 2021-12-16 18:46:33 +01:00 committed by GitHub
parent e9666458c4
commit a8168d6ee7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -172,7 +172,11 @@ export class OnePassword1PifImporter extends BaseImporter implements Importer {
return;
}
const fieldValue = field[valueKey].toString();
// TODO: when date FieldType exists, store this as a date field type instead of formatted Text if k is 'date'
const fieldValue =
field.k === "date"
? new Date(field[valueKey] * 1000).toUTCString()
: field[valueKey].toString();
const fieldDesignation =
field[designationKey] != null ? field[designationKey].toString() : null;

View File

@ -476,6 +476,19 @@ describe("1Password 1Pif Importer", () => {
// remaining fields as custom fields
expect(cipher.fields.length).toEqual(6);
const fields = cipher.fields;
expect(fields[0].name).toEqual("sex");
expect(fields[0].value).toEqual("male");
expect(fields[1].name).toEqual("birth date");
expect(fields[1].value).toEqual("Mon, 11 Mar 2019 12:01:00 GMT");
expect(fields[2].name).toEqual("occupation");
expect(fields[2].value).toEqual("Engineer");
expect(fields[3].name).toEqual("department");
expect(fields[3].value).toEqual("IT");
expect(fields[4].name).toEqual("job title");
expect(fields[4].value).toEqual("Developer");
expect(fields[5].name).toEqual("home");
expect(fields[5].value).toEqual("+49 333 222 111");
});
it("should create password history", async () => {