Account deletion button

pull/1/head
yflory 7 years ago
parent c135893638
commit 07e361b88d

@ -88,6 +88,10 @@ define([
};
postMessage("MIGRATE_ANON_DRIVE", data, cb);
};
// Settings
common.deleteAccount = function (cb) {
postMessage("DELETE_ACCOUNT", null, cb);
};
// Drive
common.userObjectCommand = function (data, cb) {
postMessage("DRIVE_USEROBJECT", data, cb);

@ -1,4 +1,5 @@
define([
'json.sortify',
'/common/userObject.js',
'/common/migrate-user-object.js',
'/common/common-hash.js',
@ -15,7 +16,7 @@ define([
'/bower_components/chainpad-crypto/crypto.js?v=0.1.5',
'/bower_components/chainpad/chainpad.dist.js',
'/bower_components/chainpad-listmap/chainpad-listmap.js',
], function (UserObject, Migrate, Hash, Util, Constants, Feedback, Realtime, Messaging, Messenger,
], function (Sortify, UserObject, Migrate, Hash, Util, Constants, Feedback, Realtime, Messaging, Messenger,
CpNfWorker, NetConfig, AppConfig,
Crypto, ChainPad, Listmap) {
var Store = {};
@ -420,6 +421,23 @@ define([
});
};
Store.deleteAccount = function (data, cb) {
var toSign = {
intent: 'Please delete my account.'
};
var secret = Hash.getSecrets('drive', storeHash);
toSign.drive = secret.channel;
toSign.edPublic = store.proxy.edPublic;
var signKey = Crypto.Nacl.util.decodeBase64(secret.keys.signKey);
console.log(Sortify(toSign));
var proof = Crypto.Nacl.sign.detached(Crypto.Nacl.util.decodeUTF8(Sortify(toSign)), signKey);
var proofTxt = Crypto.Nacl.util.encodeBase64(proof);
cb({
proof: proofTxt,
toSign: JSON.parse(Sortify(toSign))
});
};
/**
* add a "What is CryptPad?" pad in the drive
* data

@ -172,7 +172,10 @@ define([
case 'DRIVE_USEROBJECT': {
Store.userObjectCommand(data, cb); break;
}
// Settings
case 'DELETE_ACCOUNT': {
Store.deleteAccount(data, cb); break;
}
case 'IS_NEW_CHANNEL': {
Store.isNewChannel(data, cb); break;
}

@ -193,6 +193,7 @@ define({
'Q_SETTINGS_LOGOUT': true,
// Import pads from this computer's anon session into the current user account
'Q_SETTINGS_IMPORT_LOCAL': true,
'Q_SETTINGS_DELETE_ACCOUNT': true,
// Store the language selected in the iframe into localStorage outside
'Q_LANGUAGE_SET': true,

@ -138,5 +138,9 @@
}
}
}
.cp-app-settings-delete-alert {
pre { color: inherit; }
}
}

@ -47,7 +47,8 @@ define([
'cp-settings-logout-everywhere',
'cp-settings-resettips',
'cp-settings-thumbnails',
'cp-settings-userfeedback'
'cp-settings-userfeedback',
'cp-settings-delete'
],
'creation': [
'cp-settings-creation-owned',
@ -317,6 +318,48 @@ define([
return $div;
};
create['delete'] = function () {
var $div = $('<div>', { 'class': 'cp-settings-delete cp-sidebarlayout-element'});
$('<span>', {'class': 'label'}).text('DELETE ACCOUNT').appendTo($div); // XXX
$('<span>', {'class': 'cp-sidebarlayout-description'})
.append('DELETE ACCOUNT DESCRIPTION').appendTo($div); // XXX
//var $ok = $('<span>', {'class': 'fa fa-check', title: Messages.saved});
var $spinner = $('<span>', {'class': 'fa fa-spinner fa-pulse'});
var $button = $('<button>', {'id': 'cp-settings-delete', 'class': 'btn btn-primary'})
.text('DELETE MY ACCOUNT PERMANENTLY').appendTo($div); // XXX
$button.click(function () {
$spinner.show();
sframeChan.query("Q_SETTINGS_DELETE_ACCOUNT", null, function (err, data) {
var msg = h('div.cp-app-settings-delete-alert', [
h('p', 'SEND US THE FOLLOWING DATA'),
h('pre', JSON.stringify(data, 0, 2))
]);
UI.alert(msg);
$spinner.hide();
});
// TODO
/*
UI.confirm("Are you sure?", function (yes) {
// Logout everywhere
// Disconnect other tabs
// Remove owned pads
// Remove owned drive
// Remove pinstore
// Alert: "Account deleted", press OK to be redirected to the home page
$spinner.hide();
});*/
});
$spinner.hide().appendTo($div);
return $div;
};
// Pad Creation settings
var setHTML = function (e, html) {

@ -65,6 +65,9 @@ define([
sframeChan.on('Q_SETTINGS_IMPORT_LOCAL', function (data, cb) {
Cryptpad.mergeAnonDrive(cb);
});
sframeChan.on('Q_SETTINGS_DELETE_ACCOUNT', function (data, cb) {
Cryptpad.deleteAccount(cb);
});
};
var category;
if (window.location.hash) {

Loading…
Cancel
Save