mirror of
https://github.com/nextcloud/passman.git
synced 2025-01-27 09:49:02 +08:00
Add lastpass importer
This commit is contained in:
parent
9f5f00c91c
commit
31a85bf673
3 changed files with 39 additions and 2 deletions
|
@ -6,16 +6,22 @@ if(!window['PassmanImporter']){
|
|||
PassmanImporter.parseRow_ = function(row, isHeading) {
|
||||
// Strip leading quote.
|
||||
row = row.trim();
|
||||
var isQuoted = false;
|
||||
if (row.charAt(0) == '"') {
|
||||
row = row.substring(1);
|
||||
isQuoted = true;
|
||||
}
|
||||
if (row.charAt(row.length - 2) == '"') {
|
||||
row = row.substring(0, row.length - 2);
|
||||
isQuoted = true;
|
||||
}
|
||||
// Strip trailing quote. There seems to be a character between the last quote
|
||||
// and the line ending, hence 2 instead of 1.
|
||||
|
||||
row = row.split('","');
|
||||
if(isQuoted == true) {
|
||||
row = row.split('","');
|
||||
} else {
|
||||
row = row.split(',');
|
||||
}
|
||||
return row;
|
||||
};
|
||||
|
||||
|
@ -69,6 +75,7 @@ PassmanImporter.readCsv = function( csv ){
|
|||
var lines = [];
|
||||
var rows = csv.split('\n');
|
||||
var headings = this.parseRow_(rows[0]);
|
||||
|
||||
for (var i = 1, row; row = rows[i]; i++) {
|
||||
row = this.toObject_(headings, this.parseRow_(row));
|
||||
lines.push(row);
|
||||
|
|
29
js/importers/importer-lastpasscsv.js
Normal file
29
js/importers/importer-lastpasscsv.js
Normal file
|
@ -0,0 +1,29 @@
|
|||
// Importers should always start with this
|
||||
if (!window['PassmanImporter']) {
|
||||
var PassmanImporter = {}
|
||||
}
|
||||
// Define the importer
|
||||
PassmanImporter.lastpassCsv = {
|
||||
info: {
|
||||
name: 'LastPass csv',
|
||||
id: 'lastpassCsv',
|
||||
description: 'Create an csv export. Go to More options -> Advanced -> Export -> Last Pass CSV File'
|
||||
}
|
||||
};
|
||||
|
||||
PassmanImporter.lastpassCsv.readFile = function (file_data) {
|
||||
var parsed_csv = PassmanImporter.readCsv(file_data);
|
||||
var credential_list = [];
|
||||
for (var i = 0; i < parsed_csv.length; i++) {
|
||||
var row = parsed_csv[i];
|
||||
var _credential = PassmanImporter.newCredential();
|
||||
_credential.label = row.name;
|
||||
_credential.username = row.username;
|
||||
_credential.password = row.password;
|
||||
_credential.url = row.url;
|
||||
_credential.tags = [{text: row.grouping}];
|
||||
_credential.description = row.extra;
|
||||
credential_list.push(_credential);
|
||||
}
|
||||
return credential_list;
|
||||
};
|
|
@ -60,6 +60,7 @@ script('passman', 'app/directives/credentialfield');
|
|||
script('passman', 'app/directives/ngenter');
|
||||
script('passman', 'importers/import-main');
|
||||
script('passman', 'importers/importer-keepasscsv');
|
||||
script('passman', 'importers/importer-lastpasscsv');
|
||||
|
||||
/*
|
||||
* Styles
|
||||
|
|
Loading…
Reference in a new issue