Handle error when the device id mismatch

This commit is contained in:
Gustavo Maximiliano Cortez 2015-10-28 16:19:16 -03:00
commit ca7ec8e392
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF
3 changed files with 18 additions and 9 deletions

View file

@ -41,15 +41,21 @@ angular.module('copayApp.services')
json = JSON.parse(text);
} catch (e) {};
if (!json) return cb('Could not access storage')
if (!json.iter || !json.ct)
return cb(null, text);
$log.debug('Profile is encrypted');
getUUID(function(uuid) {
if (!uuid)
return cb(new Error('Could not decrypt localstorage profile'));
return cb('Could not decrypt storage: could not get device ID');
text = sjcl.decrypt(uuid, text);
try {
text = sjcl.decrypt(uuid, text);
} catch(e) {
return cb('Could not decrypt storage: device ID mismatch');
};
return cb(null, text);
});
};