mirror of https://github.com/BTCPrivate/copay.git
add preconditions
This commit is contained in:
parent
aac98f7857
commit
60251f87f0
|
@ -2,6 +2,7 @@ var cryptoUtil = require('../util/crypto');
|
||||||
var log = require('../util/log');
|
var log = require('../util/log');
|
||||||
var LocalStorage = require('./LocalStorage');
|
var LocalStorage = require('./LocalStorage');
|
||||||
var inherits = require('inherits');
|
var inherits = require('inherits');
|
||||||
|
var preconditions = require('preconditions').singleton();
|
||||||
|
|
||||||
var SEPARATOR = '@#$';
|
var SEPARATOR = '@#$';
|
||||||
|
|
||||||
|
@ -30,8 +31,12 @@ EncryptedLocalStorage.prototype._brokenDecryptUndef = function(body) {
|
||||||
|
|
||||||
EncryptedLocalStorage.prototype.getItem = function(name, callback) {
|
EncryptedLocalStorage.prototype.getItem = function(name, callback) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
preconditions.checkState(self.email);
|
||||||
|
|
||||||
LocalStorage.prototype.getItem.apply(this, [name,
|
LocalStorage.prototype.getItem.apply(this, [name,
|
||||||
function(err, body) {
|
function(err, body) {
|
||||||
|
|
||||||
|
|
||||||
var decryptedJson = cryptoUtil.decrypt(self.email + SEPARATOR + self.password, body);
|
var decryptedJson = cryptoUtil.decrypt(self.email + SEPARATOR + self.password, body);
|
||||||
if (!decryptedJson) {
|
if (!decryptedJson) {
|
||||||
log.debug('Could not decrypt value using current decryption schema');
|
log.debug('Could not decrypt value using current decryption schema');
|
||||||
|
|
Loading…
Reference in New Issue