import error check

This commit is contained in:
Mo Bitar
2017-01-29 00:19:32 -06:00
parent 5ec6fc4831
commit 48ea5dc22c
3 changed files with 12 additions and 10 deletions

View File

@@ -56,7 +56,6 @@ angular.module('app.frontend')
} }
$scope.tagsSave = function(tag, callback) { $scope.tagsSave = function(tag, callback) {
console.log("saving tag", tag);
if(!tag.title || tag.title.length == 0) { if(!tag.title || tag.title.length == 0) {
$scope.notesRemoveTag(tag); $scope.notesRemoveTag(tag);
return; return;

View File

@@ -117,13 +117,13 @@ class AccountMenu {
// allow loading indicator to come up with timeout // allow loading indicator to come up with timeout
$timeout(function(){ $timeout(function(){
$scope.importJSONData(data, password, function(response){ $scope.importJSONData(data, password, function(response){
// console.log("Import response:", success, response); $timeout(function(){
$scope.importData.loading = false; $scope.importData.loading = false;
if(response) {
$scope.importData = null; $scope.importData = null;
} else { if(!response) {
alert("There was an error importing your data. Please try again."); alert("There was an error importing your data. Please try again.");
} }
})
}) })
}) })
} }
@@ -171,7 +171,7 @@ class AccountMenu {
Neeto.crypto.computeEncryptionKeysForUser(_.merge({password: password}, data.auth_params), function(keys){ Neeto.crypto.computeEncryptionKeysForUser(_.merge({password: password}, data.auth_params), function(keys){
var mk = keys.mk; var mk = keys.mk;
try { try {
EncryptionHelper.decryptMultipleItems(data.items, mk); EncryptionHelper.decryptMultipleItems(data.items, mk, true);
// delete items enc_item_key since the user's actually key will do the encrypting once its passed off // delete items enc_item_key since the user's actually key will do the encrypting once its passed off
data.items.forEach(function(item){ data.items.forEach(function(item){
item.enc_item_key = null; item.enc_item_key = null;
@@ -182,7 +182,7 @@ class AccountMenu {
catch (e) { catch (e) {
console.log("Error decrypting", e); console.log("Error decrypting", e);
alert("There was an error decrypting your items. Make sure the password you entered is correct and try again."); alert("There was an error decrypting your items. Make sure the password you entered is correct and try again.");
callback(false, null); callback(null);
return; return;
} }
}.bind(this)); }.bind(this));

View File

@@ -34,7 +34,7 @@ class EncryptionHelper {
item.content = content; item.content = content;
} }
static decryptMultipleItems(items, key) { static decryptMultipleItems(items, key, throws) {
for (var item of items) { for (var item of items) {
if(item.deleted == true) { if(item.deleted == true) {
continue; continue;
@@ -51,6 +51,9 @@ class EncryptionHelper {
item.content = Neeto.crypto.base64Decode(item.content.substring(3, item.content.length)) item.content = Neeto.crypto.base64Decode(item.content.substring(3, item.content.length))
} }
} catch (e) { } catch (e) {
if(throws) {
throw e;
}
console.log("Error decrypting item", item, e); console.log("Error decrypting item", item, e);
continue; continue;
} }