From d960c10a31341502ae7e4a60128530b4adc48300 Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 10 Aug 2021 18:46:10 +0530 Subject: [PATCH] clear login token when deleting your account and before logging in --- customize.dist/login.js | 1 + www/common/outer/local-store.js | 4 ++++ www/settings/inner.js | 10 +++++----- www/settings/main.js | 4 ++++ 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/customize.dist/login.js b/customize.dist/login.js index 3309190c0..5cab49934 100644 --- a/customize.dist/login.js +++ b/customize.dist/login.js @@ -463,6 +463,7 @@ define([ var proceed = function (result) { hashing = false; if (test && typeof test === "function" && test()) { return; } + LocalStore.clearLoginToken(); Realtime.whenRealtimeSyncs(result.realtime, function () { Exports.redirect(); }); diff --git a/www/common/outer/local-store.js b/www/common/outer/local-store.js index fb49d084d..77d36645c 100644 --- a/www/common/outer/local-store.js +++ b/www/common/outer/local-store.js @@ -82,6 +82,10 @@ define([ } catch (err) { return; } }; + LocalStore.clearLoginToken = function () { + localStorage.removeItem(Constants.loginToken); + }; + LocalStore.setDriveRedirectPreference = function (bool) { localStorage.setItem(Constants.redirectToDriveKey, Boolean(bool)); }; diff --git a/www/settings/inner.js b/www/settings/inner.js index 2d29f0f05..798af282b 100644 --- a/www/settings/inner.js +++ b/www/settings/inner.js @@ -542,12 +542,12 @@ define([ } // Owned drive if (data.state === true) { - sframeChan.query('Q_SETTINGS_LOGOUT', null, function() {}); - UI.alert(Messages.settings_deleted, function() { - common.gotoURL('/'); + return void sframeChan.query('Q_SETTINGS_LOGOUT_PROPERLY', null, function() { + UI.alert(Messages.settings_deleted, function() { + common.gotoURL('/'); + }); + spinner.done(); }); - spinner.done(); - return; } // Not owned drive var msg = h('div.cp-app-settings-delete-alert', [ diff --git a/www/settings/main.js b/www/settings/main.js index 8101203b1..189d94eb5 100644 --- a/www/settings/main.js +++ b/www/settings/main.js @@ -57,6 +57,10 @@ define([ }); }); }); + sframeChan.on('Q_SETTINGS_LOGOUT_PROPERLY', function (data, cb) { + Utils.LocalStore.clearLoginToken(); + cb(); + }); sframeChan.on('Q_SETTINGS_DRIVE_RESET', function (data, cb) { Cryptpad.resetDrive(cb); });