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) { CipherString.prototype.decrypt = function (callback) {
if (!_decryptedValue) { if (!_decryptedValue) {
var cryptoService = chrome.extension.getBackgroundPage().cryptoService; 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) { siteService.getAll(function (sites) {
for (var i = 0; i < folders.length; i++) { for (var i = 0; i < folders.length; i++) {
decFolders.push({ decFolders.push({
id: folders[i].id, id: folders[i].id
name: folders[i].name.decrypt() });
folders[i].name.decrypt(function (name) {
decFolders.name = name;
}); });
} }
@ -25,10 +28,20 @@
decSites.push({ decSites.push({
id: sites[j].id, id: sites[j].id,
folderId: sites[j].folderId, folderId: sites[j].folderId,
favorite: sites[j].favorite, favorite: sites[j].favorite
name: sites[j].name.decrypt(),
username: sites[j].username.decrypt()
}); });
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; $scope.sites = decSites;

View File

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