fix references

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

View file

@ -1,6 +1,7 @@
var cryptoUtil = require('../util/crypto'); var cryptoUtil = require('../util/crypto');
var InsightStorage = require('./InsightStorage'); var InsightStorage = require('./InsightStorage');
var inherits = require('inherits'); var inherits = require('inherits');
var log = require('../log');
function EncryptedInsightStorage(config) { function EncryptedInsightStorage(config) {
InsightStorage.apply(this, [config]); InsightStorage.apply(this, [config]);
@ -16,16 +17,17 @@ EncryptedInsightStorage.prototype._brokenDecrypt = function(body) {
}; };
EncryptedInsightStorage.prototype.getItem = function(name, callback) { EncryptedInsightStorage.prototype.getItem = function(name, callback) {
var self = this;
InsightStorage.prototype.getItem.apply(this, [name, InsightStorage.prototype.getItem.apply(this, [name,
function(err, body) { function(err, body) {
if (err) { if (err) {
return callback(err); return callback(err);
} }
var decryptedJson = cryptoUtil.decrypt(this.password, body); var decryptedJson = cryptoUtil.decrypt(self.password, body);
log.debug('Could not decrypt value using current decryption schema');
if (!decryptedJson) { if (!decryptedJson) {
decryptedJson = this._brokenDecrypt(body); log.debug('Could not decrypt value using current decryption schema');
decryptedJson = self._brokenDecrypt(body);
} }
if (!decryptedJson) { if (!decryptedJson) {

View file

@ -1,4 +1,5 @@
var cryptoUtil = require('../util/crypto'); var cryptoUtil = require('../util/crypto');
var log = require('../log');
var LocalStorage = require('./LocalStorage'); var LocalStorage = require('./LocalStorage');
var inherits = require('inherits'); var inherits = require('inherits');
@ -17,13 +18,14 @@ EncryptedLocalStorage.prototype._brokenDecrypt = function(body) {
EncryptedLocalStorage.prototype.getItem = function(name, callback) { EncryptedLocalStorage.prototype.getItem = function(name, callback) {
var self = this;
LocalStorage.prototype.getItem.apply(this, [name, LocalStorage.prototype.getItem.apply(this, [name,
function(err, body) { function(err, body) {
var decryptedJson = cryptoUtil.decrypt(this.password, body); var decryptedJson = cryptoUtil.decrypt(self.password, body);
log.debug('Could not decrypt value using current decryption schema');
if (!decryptedJson) { if (!decryptedJson) {
decryptedJson = this._brokenDecrypt(body); log.debug('Could not decrypt value using current decryption schema');
decryptedJson = self._brokenDecrypt(body);
} }
if (!decryptedJson) { if (!decryptedJson) {