remove profile

This commit is contained in:
Ivan Socolsky 2014-12-01 14:44:36 -03:00
parent 90136f1c30
commit 14cb044990
3 changed files with 40 additions and 1 deletions

View File

@ -55,6 +55,16 @@ angular.module('copayApp.controllers').controller('ProfileController', function(
};
$scope.deleteProfile = function () {
identityService.deleteProfile(function (err, res) {
if (err) {
log.warn(err);
notification.error('Error', 'Could not delete profile');
return;
}
$location.path('/');
setTimeout(function () {
notification.error('Success', 'Profile successfully deleted');
}, 1);
});
};
});

View File

@ -307,6 +307,31 @@ Identity.prototype.store = function(opts, cb) {
});
};
/**
* @param {Object} opts
* @param {Function} cb
*/
Identity.prototype.remove = function(opts, cb) {
log.debug('Deleting profile');
var self = this;
opts = opts || {};
// HACK (isocolsky): remove notifications while deleting wallets
self.removeAllListeners('deletedWallet');
async.each(_.values(self.wallets), function(w, cb) {
self.deleteWallet(w.getId(), cb);
}, function (err) {
if (err) return cb(err);
self.storage.removeItem(self.getId(), function(err) {
if (err) return cb(err);
self.emitAndKeepAlive('closed');
return cb();
});
});
};
Identity.prototype._cleanUp = function() {
// NOP
};

View File

@ -87,6 +87,10 @@ angular.module('copayApp.services')
});
};
root.deleteProfile = function (cb) {
$rootScope.iden.remove(null, cb);
};
root.deleteWallet = function(w, cb) {
$rootScope.iden.deleteWallet(w.id, cb);
};