support old CSV format for password agent

This commit is contained in:
Kyle Spearrin 2019-06-21 08:19:38 -04:00
parent 49a6b5046f
commit 6d82fb5bbc
1 changed files with 14 additions and 7 deletions

View File

@ -12,25 +12,32 @@ export class PasswordAgentCsvImporter extends BaseImporter implements Importer {
return result;
}
let newVersion = true;
results.forEach((value) => {
if (value.length < 9) {
if (value.length !== 5 && value.length < 9) {
return;
}
const folder = this.getValueOrDefault(value[8], '(None)');
const folderName = folder !== '(None)' ? folder.split('\\').join('/') : null;
this.processFolder(result, folderName);
const cipher = this.initLoginCipher();
cipher.notes = this.getValueOrDefault(value[3]);
cipher.name = this.getValueOrDefault(value[0], '--');
cipher.login.username = this.getValueOrDefault(value[1]);
cipher.login.password = this.getValueOrDefault(value[2]);
cipher.login.uris = this.makeUriArray(value[4]);
if (value.length === 5) {
newVersion = false;
cipher.notes = this.getValueOrDefault(value[4]);
cipher.login.uris = this.makeUriArray(value[3]);
} else {
const folder = this.getValueOrDefault(value[8], '(None)');
const folderName = folder !== '(None)' ? folder.split('\\').join('/') : null;
this.processFolder(result, folderName);
cipher.notes = this.getValueOrDefault(value[3]);
cipher.login.uris = this.makeUriArray(value[4]);
}
this.convertToNoteIfNeeded(cipher);
this.cleanupCipher(cipher);
result.ciphers.push(cipher);
});
if (this.organization) {
if (newVersion && this.organization) {
this.moveFoldersToCollections(result);
}