fix references

This commit is contained in:
Matias Alejo Garcia 2014-11-10 23:08:14 -03:00
parent 7942048dd1
commit 5ca398a97a
2 changed files with 10 additions and 6 deletions

View File

@ -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) {

View File

@ -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) {