commit
57b98d24d4
7 changed files with 42 additions and 10 deletions
|
|
@ -356,8 +356,13 @@ Identity.prototype.remove = function(opts, cb) {
|
|||
|
||||
self.storage.removeItem(self.getId(), function(err) {
|
||||
if (err) return cb(err);
|
||||
self.emitAndKeepAlive('closed');
|
||||
return cb();
|
||||
|
||||
self.storage.clear(function (err) {
|
||||
if (err) return cb(err);
|
||||
|
||||
self.emitAndKeepAlive('closed');
|
||||
return cb();
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -49,4 +49,8 @@ EncryptedInsightStorage.prototype.removeItem = function(name, callback) {
|
|||
InsightStorage.prototype.removeItem.apply(this, [name, callback]);
|
||||
};
|
||||
|
||||
EncryptedInsightStorage.prototype.clear = function(callback) {
|
||||
InsightStorage.prototype.clear.apply(this, [callback]);
|
||||
};
|
||||
|
||||
module.exports = EncryptedInsightStorage;
|
||||
|
|
|
|||
|
|
@ -52,6 +52,9 @@ EncryptedLocalStorage.prototype.removeItem = function(name, callback) {
|
|||
LocalStorage.prototype.removeItem.apply(this, [name, callback]);
|
||||
};
|
||||
|
||||
EncryptedLocalStorage.prototype.clear = function(callback) {
|
||||
LocalStorage.prototype.clear.apply(this, [callback]);
|
||||
};
|
||||
|
||||
|
||||
module.exports = EncryptedLocalStorage;
|
||||
|
|
|
|||
|
|
@ -232,8 +232,28 @@ InsightStorage.prototype.removeItem = function(key, callback) {
|
|||
};
|
||||
|
||||
InsightStorage.prototype.clear = function(callback) {
|
||||
// NOOP
|
||||
callback();
|
||||
var passphrase = this.getPassphrase();
|
||||
var authHeader = new buffers.Buffer(this.email + ':' + passphrase).toString('base64');
|
||||
var deleteUrl = this.storeUrl + '/delete/profile';
|
||||
|
||||
log.debug('Clearing storage for: ' + this.email);
|
||||
this.request.post({
|
||||
url: deleteUrl,
|
||||
headers: {
|
||||
'Authorization': authHeader
|
||||
},
|
||||
body: null,
|
||||
}, function(err, response, body) {
|
||||
if (err) {
|
||||
return callback('Connection error');
|
||||
}
|
||||
if (response.statusCode === 409) {
|
||||
return callback('BADCREDENTIALS: Invalid username or password');
|
||||
} else if (response.statusCode !== 200) {
|
||||
return callback('Unable to remove data on insight');
|
||||
}
|
||||
return callback();
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = InsightStorage;
|
||||
|
|
|
|||
|
|
@ -80,11 +80,7 @@ LocalStorage.prototype.removeItem = function(k, cb) {
|
|||
};
|
||||
|
||||
LocalStorage.prototype.clear = function(cb) {
|
||||
if (isChromeApp) {
|
||||
chrome.storage.clear();
|
||||
} else {
|
||||
this.ls.clear();
|
||||
}
|
||||
// NOP
|
||||
return cb();
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue