Ability to burn an anonymous drive from the browser

pull/1/head
yflory 7 years ago
parent 4b5abdecbe
commit 9795ac32cb

@ -395,6 +395,9 @@ define(function () {
out.fm_viewGridButton = "Grille"; out.fm_viewGridButton = "Grille";
out.fm_renamedPad = "Vous avez renommé ce pad dans votre Drive. Son titre est:<br><b>{0}</b>"; out.fm_renamedPad = "Vous avez renommé ce pad dans votre Drive. Son titre est:<br><b>{0}</b>";
out.fm_prop_tagsList = "Mots-clés"; out.fm_prop_tagsList = "Mots-clés";
out.fm_burnThisDriveButton = "Effacer toutes les informations stockées par CryptPad dans votre navigateur";
out.fm_burnThisDrive = "Êtes-vous sûr de vouloir supprimmer tout ce qui est stocké par CryptPad dans votre navigateur ?<br>" +
"Cette action supprimera votre CryptDrive et son historique de votre navigateur, mais les pads existeront toujours (de manière chiffrée) sur notre serveur.";
// File - Context menu // File - Context menu
out.fc_newfolder = "Nouveau dossier"; out.fc_newfolder = "Nouveau dossier";
out.fc_rename = "Renommer"; out.fc_rename = "Renommer";

@ -397,6 +397,9 @@ define(function () {
out.fm_viewGridButton = "Grid view"; out.fm_viewGridButton = "Grid view";
out.fm_renamedPad = "You've set a custom name for this pad. Its shared title is:<br><b>{0}</b>"; out.fm_renamedPad = "You've set a custom name for this pad. Its shared title is:<br><b>{0}</b>";
out.fm_prop_tagsList = "Tags"; out.fm_prop_tagsList = "Tags";
out.fm_burnThisDriveButton = "Erase all information stored by CryptPad in your browser";
out.fm_burnThisDrive = "Are you sure you want to remove everything stored by CryptPad in your browser?<br>" +
"This will remove your CryptDrive and its history from your browser, but your pads will still exist (encrypted) on our server.";
// File - Context menu // File - Context menu
out.fc_newfolder = "New folder"; out.fc_newfolder = "New folder";
out.fc_rename = "Rename"; out.fc_rename = "Rename";

@ -194,4 +194,7 @@ define({
// Store the language selected in the iframe into localStorage outside // Store the language selected in the iframe into localStorage outside
'Q_LANGUAGE_SET': true, 'Q_LANGUAGE_SET': true,
// Anonymous users can empty their drive and remove FS_hash from localStorage
'EV_BURN_ANON_DRIVE': true,
}); });

@ -1826,6 +1826,9 @@ define([
.appendTo($toolbar); .appendTo($toolbar);
var $hist = common.createButton('history', true, {histConfig: APP.histConfig}); var $hist = common.createButton('history', true, {histConfig: APP.histConfig});
$rightside.append($hist); $rightside.append($hist);
if (APP.$burnThisDrive) {
$rightside.append(APP.$burnThisDrive);
}
return $toolbar; return $toolbar;
}; };
@ -2989,10 +2992,12 @@ define([
APP.$displayName = APP.$bar.find('.' + Toolbar.constants.username); APP.$displayName = APP.$bar.find('.' + Toolbar.constants.username);
/* add the usage */ /* add the usage */
if (APP.loggedIn) {
common.createUsageBar(function (err, $limitContainer) { common.createUsageBar(function (err, $limitContainer) {
if (err) { return void logError(err); } if (err) { return void logError(err); }
APP.$limit = $limitContainer; APP.$limit = $limitContainer;
}, true); }, true);
}
/* add a history button */ /* add a history button */
APP.histConfig = { APP.histConfig = {
@ -3009,6 +3014,18 @@ define([
$toolbar: APP.$bar, $toolbar: APP.$bar,
}; };
// Add a "Burn this drive" button
if (!APP.loggedIn) {
APP.$burnThisDrive = common.createButton(null, true).click(function () {
UI.confirm(Messages.fm_burnThisDrive, function (yes) {
if (!yes) { return; }
common.getSframeChannel().event('EV_BURN_ANON_DRIVE');
}, null, true);
}).attr('title', Messages.fm_burnThisDriveButton)
.removeClass('fa-question')
.addClass('fa-ban');
}
metadataMgr.onChange(function () { metadataMgr.onChange(function () {
var name = metadataMgr.getUserData().name || Messages.anonymous; var name = metadataMgr.getUserData().name || Messages.anonymous;
APP.$displayName.text(name); APP.$displayName.text(name);

@ -43,11 +43,20 @@ define([
Utils.LocalStore.getFSHash(); Utils.LocalStore.getFSHash();
return Utils.Hash.getSecrets('drive', hash); return Utils.Hash.getSecrets('drive', hash);
}; };
var addRpc = function (sframeChan, Cryptpad, Utils) {
sframeChan.on('EV_BURN_ANON_DRIVE', function () {
if (Utils.LocalStore.isLoggedIn()) { return; }
Utils.LocalStore.setFSHash('');
Utils.LocalStore.clearThumbnail();
window.location.reload();
});
};
Netflux.connect(NetConfig.getWebsocketURL()).then(function (network) { Netflux.connect(NetConfig.getWebsocketURL()).then(function (network) {
SFCommonO.start({ SFCommonO.start({
getSecrets: getSecrets, getSecrets: getSecrets,
newNetwork: network, newNetwork: network,
noHash: true noHash: true,
addRpc: addRpc
}); });
}, function (err) { console.error(err); }); }, function (err) { console.error(err); });
}); });

Loading…
Cancel
Save