mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 16:23:44 +00:00
catch bad data on all importers
This commit is contained in:
@@ -13,10 +13,17 @@
|
||||
|
||||
function importSuccess(folders, sites, folderRelationships) {
|
||||
if (!folders.length && !sites.length) {
|
||||
$uibModalInstance.dismiss('cancel');
|
||||
toastr.error('Nothing was imported.');
|
||||
importError('Nothing was imported.');
|
||||
return;
|
||||
}
|
||||
else if (sites.length) {
|
||||
var halfway = Math.floor(sites.length / 2);
|
||||
var last = sites.length - 1;
|
||||
if (siteIsBadData(sites[0]) && siteIsBadData(sites[halfway]) && siteIsBadData(sites[last])) {
|
||||
importError('CSV data is not formatted correctly. Please check your import file and try again.');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
apiService.ciphers.import({
|
||||
folders: cipherService.encryptFolders(folders, cryptoService.getKey()),
|
||||
@@ -31,6 +38,10 @@
|
||||
}, importError);
|
||||
}
|
||||
|
||||
function siteIsBadData(site) {
|
||||
return (site.name === null || site.name === '--') && (site.password === null || site.password === '');
|
||||
}
|
||||
|
||||
function importError(error) {
|
||||
$analytics.eventTrack('Import Data Failed', { label: $scope.model.source });
|
||||
$uibModalInstance.dismiss('cancel');
|
||||
|
||||
Reference in New Issue
Block a user