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) {
console.log("saving tag", tag);
if(!tag.title || tag.title.length == 0) {
$scope.notesRemoveTag(tag);
return;

View File

@@ -117,13 +117,13 @@ class AccountMenu {
// allow loading indicator to come up with timeout
$timeout(function(){
$scope.importJSONData(data, password, function(response){
// console.log("Import response:", success, response);
$scope.importData.loading = false;
if(response) {
$timeout(function(){
$scope.importData.loading = false;
$scope.importData = null;
} else {
alert("There was an error importing your data. Please try again.");
}
if(!response) {
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){
var mk = keys.mk;
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
data.items.forEach(function(item){
item.enc_item_key = null;
@@ -182,7 +182,7 @@ class AccountMenu {
catch (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.");
callback(false, null);
callback(null);
return;
}
}.bind(this));

View File

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