mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-23 11:56:00 +01:00
avira json importer
This commit is contained in:
parent
1f6677d610
commit
6aaa47cccd
@ -68,6 +68,9 @@
|
||||
case 'clipperzhtml':
|
||||
importClipperzHtml(file, success, error);
|
||||
break;
|
||||
case 'avirajson':
|
||||
importAviraJson(file, success, error);
|
||||
break;
|
||||
default:
|
||||
error();
|
||||
break;
|
||||
@ -1645,5 +1648,59 @@
|
||||
};
|
||||
}
|
||||
|
||||
function importAviraJson(file, success, error) {
|
||||
var folders = [],
|
||||
sites = [],
|
||||
siteRelationships = [],
|
||||
i = 0;
|
||||
|
||||
var reader = new FileReader();
|
||||
reader.readAsText(file, 'utf-8');
|
||||
reader.onload = function (evt) {
|
||||
var fileContent = evt.target.result;
|
||||
var fileJson = JSON.parse(fileContent);
|
||||
if (fileJson) {
|
||||
if (fileJson.accounts) {
|
||||
for (i = 0; i < fileJson.accounts.length; i++) {
|
||||
var account = fileJson.accounts[i];
|
||||
var site = {
|
||||
favorite: account.is_favorite && account.is_favorite === true,
|
||||
uri: account.domain && account.domain !== '' ? trimUri(account.domain) : null,
|
||||
username: account.username && account.username !== '' ? account.username : null,
|
||||
password: account.password && account.password !== '' ? account.password : null,
|
||||
notes: null,
|
||||
name: account.label && account.label !== '' ? account.label : account.domain,
|
||||
};
|
||||
|
||||
if (account.email && account.email !== '') {
|
||||
if (!site.username || site.username === '') {
|
||||
site.username = account.email;
|
||||
}
|
||||
else {
|
||||
site.notes = account.email;
|
||||
}
|
||||
}
|
||||
|
||||
if (!site.name || site.name === '') {
|
||||
site.name = '--';
|
||||
}
|
||||
|
||||
if (site.uri && !site.uri.startsWith('http')) {
|
||||
site.uri = 'http://' + site.uri;
|
||||
}
|
||||
|
||||
sites.push(site);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
success(folders, sites, siteRelationships);
|
||||
};
|
||||
|
||||
reader.onerror = function (evt) {
|
||||
error();
|
||||
};
|
||||
}
|
||||
|
||||
return _service;
|
||||
});
|
||||
|
@ -26,6 +26,7 @@
|
||||
<option value="msecurecsv">mSecure (csv)</option>
|
||||
<option value="truekeyjson">True Key (json)</option>
|
||||
<option value="clipperzhtml">Clipperz (html)</option>
|
||||
<option value="avirajson">Avira (json)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
Loading…
Reference in New Issue
Block a user