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

export data fixes due to api cahnges

This commit is contained in:
Kyle Spearrin 2017-04-12 16:41:31 -04:00
parent 0591f106d3
commit da8b31533a
2 changed files with 26 additions and 11 deletions

View File

@ -37,12 +37,6 @@ angular
notes: encryptedLogin.Notes && encryptedLogin.Notes !== '' ? cryptoService.decrypt(encryptedLogin.Notes, key) : null
};
if (encryptedLogin.Folder) {
login.folder = {
name: cryptoService.decrypt(encryptedLogin.Folder.Name)
};
}
return login;
};

View File

@ -5,19 +5,40 @@
$analytics.eventTrack('toolsExportController', { category: 'Modal' });
$scope.export = function (model) {
$scope.startedExport = true;
apiService.logins.list({ expand: ['folder'] }, function (logins) {
try {
var decLogins = cipherService.decryptLogins(logins.Data);
var decLogins = [],
decFolders = [];
var folderPromise = apiService.folders.list({}, function (folders) {
decFolders = cipherService.decryptFolders(folders.Data);
}).$promise;
var loginsPromise = apiService.logins.list({}, function (logins) {
decLogins = cipherService.decryptLogins(logins.Data);
}).$promise;
$q.all([folderPromise, loginsPromise]).then(function () {
if (!decLogins.length) {
toastr.error('Nothing to export.', 'Error!');
$scope.close();
return;
}
var foldersDict = {};
for (var i = 0; i < decFolders.length; i++) {
foldersDict[decFolders[i].id] = decFolders[i];
}
try {
var exportLogins = [];
for (var i = 0; i < decLogins.length; i++) {
for (i = 0; i < decLogins.length; i++) {
var login = {
name: decLogins[i].name,
uri: decLogins[i].uri,
username: decLogins[i].username,
password: decLogins[i].password,
notes: decLogins[i].notes,
folder: decLogins[i].folder ? decLogins[i].folder.name : null,
folder: decLogins[i].folderId && (decLogins[i].folderId in foldersDict) ?
foldersDict[decLogins[i].folderId].name : null,
favorite: decLogins[i].favorite ? 1 : null
};