added exception handling for password/login

This commit is contained in:
Tankred Hase 2013-05-07 15:10:51 +02:00
parent 654a89055b
commit 8f0b698d27
3 changed files with 21 additions and 3 deletions

View File

@ -41,7 +41,15 @@ app.crypto.Crypto = function(window, util) {
keyStore.persist(storageId, storedKey);
} else {
// decrypt key
symmetricUserKey = aes.decrypt(storedKey.encryptedKey, pbkdf2, storedKey.keyIV);
try {
symmetricUserKey = aes.decrypt(storedKey.encryptedKey, pbkdf2, storedKey.keyIV);
} catch (ex) {
callback({
errMsg: 'Wrong password!'
});
return;
}
}
keyId = storedKey._id;

View File

@ -29,7 +29,12 @@ app.dao.EmailDAO = function(_, crypto, devicestorage, cloudstorage, naclCrypto,
});
function initCrypto() {
crypto.init(account.get('emailAddress'), password, account.get('symKeySize'), account.get('symIvSize'), function() {
crypto.init(account.get('emailAddress'), password, account.get('symKeySize'), account.get('symIvSize'), function(err) {
if (err) {
callback(err);
return;
}
initNaclCrypto();
});
}

View File

@ -39,8 +39,13 @@
textVisible: true,
theme: 'c'
});
this.dao.init(account, password, function() {
this.dao.init(account, password, function(err) {
$.mobile.loading('hide');
if (err) {
window.alert(err.errMsg);
return;
}
window.location = '#accounts/' + account.get('emailAddress') + '/folders';
});
}