mirror of
https://github.com/bitwarden/browser.git
synced 2024-08-22 22:32:57 +02:00
Better error handling for imports. Check for bad CSV data on lastpass (when no header row is included).
This commit is contained in:
parent
93b96b3be7
commit
8313d9fa90
|
@ -172,7 +172,8 @@
|
|||
function parseData(data) {
|
||||
var folders = [],
|
||||
sites = [],
|
||||
siteRelationships = [];
|
||||
siteRelationships = [],
|
||||
badDataSites = 0;
|
||||
|
||||
angular.forEach(data, function (value, key) {
|
||||
var folderIndex = folders.length,
|
||||
|
@ -190,6 +191,10 @@
|
|||
}
|
||||
}
|
||||
|
||||
if ((!value.name || value.name === '') && (!value.password || value.password === '')) {
|
||||
badDataSites++;
|
||||
}
|
||||
|
||||
sites.push({
|
||||
favorite: value.fav === '1',
|
||||
uri: value.url && value.url !== '' ? trimUri(value.url) : null,
|
||||
|
@ -214,7 +219,12 @@
|
|||
}
|
||||
});
|
||||
|
||||
success(folders, sites, siteRelationships);
|
||||
if (badDataSites > (data.length / 2)) {
|
||||
error('CSV data is not formatted correctly from LastPass. Please check your import file and try again.');
|
||||
}
|
||||
else {
|
||||
success(folders, sites, siteRelationships);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,15 +31,40 @@
|
|||
}, importError);
|
||||
}
|
||||
|
||||
function importError(errorMessage) {
|
||||
function importError(error) {
|
||||
$analytics.eventTrack('Import Data Failed', { label: $scope.model.source });
|
||||
$uibModalInstance.dismiss('cancel');
|
||||
if (errorMessage) {
|
||||
toastr.error(errorMessage);
|
||||
}
|
||||
else {
|
||||
toastr.error('Something went wrong. Try again.', 'Oh No!');
|
||||
|
||||
if (error) {
|
||||
var data = error.data;
|
||||
if (data && data.ValidationErrors) {
|
||||
var message = '';
|
||||
for (var key in data.ValidationErrors) {
|
||||
if (!data.ValidationErrors.hasOwnProperty(key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (var i = 0; i < data.ValidationErrors[key].length; i++) {
|
||||
message += (key + ': ' + data.ValidationErrors[key][i] + ' ');
|
||||
}
|
||||
}
|
||||
|
||||
if (message !== '') {
|
||||
toastr.error(message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (data && data.Message) {
|
||||
toastr.error(data.Message);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
toastr.error(error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
toastr.error('Something went wrong. Try again.', 'Oh No!');
|
||||
}
|
||||
|
||||
$scope.close = function () {
|
||||
|
|
Loading…
Reference in New Issue
Block a user