1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-05 09:10:53 +01:00

null checks and fix email in notes

This commit is contained in:
Kyle Spearrin 2018-10-08 15:49:38 -04:00
parent 30a5257671
commit e0c32bebc7

View File

@ -13,32 +13,32 @@ export class PassmanJsonImporter extends BaseImporter implements Importer {
}
results.forEach((credential: any) => {
if (credential.tags.length > 0) {
if (credential.tags != null && credential.tags.length > 0) {
const folderName = credential.tags[0].text;
this.processFolder(result, folderName);
}
const cipher = this.initLoginCipher();
cipher.name = credential.label;
if (cipher.name.length > 30) {
if (cipher.name != null && cipher.name.length > 30) {
cipher.name = cipher.name.substring(0, 30);
}
cipher.login.username = this.getValueOrDefault(credential.username);
if (cipher.login.username === null) {
if (this.isNullOrWhitespace(cipher.login.username)) {
cipher.login.username = this.getValueOrDefault(credential.email);
} else if (credential.email !== '') {
cipher.notes += 'E-Mail: ' + credential.email;
} else if (!this.isNullOrWhitespace(credential.email)) {
cipher.notes = ('Email: ' + credential.email + '\n');
}
cipher.login.password = this.getValueOrDefault(credential.password);
cipher.login.uris = this.makeUriArray(credential.url);
cipher.notes = this.getValueOrDefault(credential.description);
if (credential.otp) {
cipher.login.totp = credential.otp.secret;
cipher.notes += this.getValueOrDefault(credential.description);
if (credential.otp != null) {
cipher.login.totp = this.getValueOrDefault(credential.otp.secret);
}
if (credential.custom_fields != null) {
credential.custom_fields.forEach((customField: any) => {
switch (customField.field_type) {
case 'text':
@ -47,6 +47,7 @@ export class PassmanJsonImporter extends BaseImporter implements Importer {
break;
}
});
}
this.convertToNoteIfNeeded(cipher);
this.cleanupCipher(cipher);