adjustments to site getall

This commit is contained in:
Kyle Spearrin 2016-09-05 11:05:27 -04:00
parent abb6f37af2
commit a7c8dec730
3 changed files with 24 additions and 8 deletions

View File

@ -13,10 +13,13 @@ var CipherString = function (encryptedString) {
CipherString.prototype.decrypt = function (callback) {
if (!_decryptedValue) {
var cryptoService = chrome.extension.getBackgroundPage().cryptoService;
_decryptedValue = cryptoService.decrypt(this);
cryptoService.decrypt(this, function (decValue) {
_decryptedValue = decValue;
callback(_decryptedValue);
});
}
return _decryptedValue;
callback(_decryptedValue);
};
}();

View File

@ -16,8 +16,11 @@
siteService.getAll(function (sites) {
for (var i = 0; i < folders.length; i++) {
decFolders.push({
id: folders[i].id,
name: folders[i].name.decrypt()
id: folders[i].id
});
folders[i].name.decrypt(function (name) {
decFolders.name = name;
});
}
@ -25,10 +28,20 @@
decSites.push({
id: sites[j].id,
folderId: sites[j].folderId,
favorite: sites[j].favorite,
name: sites[j].name.decrypt(),
username: sites[j].username.decrypt()
favorite: sites[j].favorite
});
if (sites[j].name && sites[j].name.encryptedString) {
sites[j].name.decrypt(function (name) {
decSites.name = name;
});
}
if (sites[j].username && sites[j].username.encryptedString) {
sites[j].username.decrypt(function (username) {
decSites.username = username;
});
}
}
$scope.sites = decSites;

View File

@ -132,7 +132,7 @@ function initCryptoService() {
throw 'callback function required';
}
if (cipherString === null || cipherString === undefined) {
if (cipherString === null || cipherString === undefined || !cipherString.encryptedString) {
throw 'cannot decrypt nothing';
}