From 5ca398a97ad865508559a1967966326953fb7bb5 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Mon, 10 Nov 2014 23:08:14 -0300 Subject: [PATCH] fix references --- js/plugins/EncryptedInsightStorage.js | 8 +++++--- js/plugins/EncryptedLocalStorage.js | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/js/plugins/EncryptedInsightStorage.js b/js/plugins/EncryptedInsightStorage.js index 8258aa6b1..3f91d34ba 100644 --- a/js/plugins/EncryptedInsightStorage.js +++ b/js/plugins/EncryptedInsightStorage.js @@ -1,6 +1,7 @@ var cryptoUtil = require('../util/crypto'); var InsightStorage = require('./InsightStorage'); var inherits = require('inherits'); +var log = require('../log'); function EncryptedInsightStorage(config) { InsightStorage.apply(this, [config]); @@ -16,16 +17,17 @@ EncryptedInsightStorage.prototype._brokenDecrypt = function(body) { }; EncryptedInsightStorage.prototype.getItem = function(name, callback) { + var self = this; InsightStorage.prototype.getItem.apply(this, [name, function(err, body) { if (err) { return callback(err); } - var decryptedJson = cryptoUtil.decrypt(this.password, body); - log.debug('Could not decrypt value using current decryption schema'); + var decryptedJson = cryptoUtil.decrypt(self.password, body); if (!decryptedJson) { - decryptedJson = this._brokenDecrypt(body); + log.debug('Could not decrypt value using current decryption schema'); + decryptedJson = self._brokenDecrypt(body); } if (!decryptedJson) { diff --git a/js/plugins/EncryptedLocalStorage.js b/js/plugins/EncryptedLocalStorage.js index 24ebad8e1..f2fd46451 100644 --- a/js/plugins/EncryptedLocalStorage.js +++ b/js/plugins/EncryptedLocalStorage.js @@ -1,4 +1,5 @@ var cryptoUtil = require('../util/crypto'); +var log = require('../log'); var LocalStorage = require('./LocalStorage'); var inherits = require('inherits'); @@ -17,13 +18,14 @@ EncryptedLocalStorage.prototype._brokenDecrypt = function(body) { EncryptedLocalStorage.prototype.getItem = function(name, callback) { + var self = this; LocalStorage.prototype.getItem.apply(this, [name, function(err, body) { - var decryptedJson = cryptoUtil.decrypt(this.password, body); - log.debug('Could not decrypt value using current decryption schema'); + var decryptedJson = cryptoUtil.decrypt(self.password, body); if (!decryptedJson) { - decryptedJson = this._brokenDecrypt(body); + log.debug('Could not decrypt value using current decryption schema'); + decryptedJson = self._brokenDecrypt(body); } if (!decryptedJson) {