From 470e1fc19f98fc3f381e5127bd2a3f04a6a95288 Mon Sep 17 00:00:00 2001 From: azivner Date: Sat, 30 Sep 2017 19:45:57 -0400 Subject: [PATCH] logout detection - if user is logged out then we redirect to login page --- static/js/tree.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/static/js/tree.js b/static/js/tree.js index 9f69c75a6..f4e85401d 100644 --- a/static/js/tree.js +++ b/static/js/tree.js @@ -89,12 +89,23 @@ let globalEncryptedDataKey; let globalFullLoadTime; setInterval(() => { - $.get(baseApiUrl + 'audit/' + globalFullLoadTime).then(resp => { - if (resp.changed) { - window.location.reload(true); + $.ajax({ + url: baseApiUrl + 'audit/' + globalFullLoadTime, + type: 'GET', + success: function (resp) { + if (resp.changed) { + window.location.reload(true); + } + }, + statusCode: { + 401: function() { + // if the user got logged out then we should display the page + // here we do that by reloading which will force the redirect if the user is really logged out + window.location.reload(true); + } } }); -}, 60 * 1000); +}, 10 * 1000); $(function(){ $.get(baseApiUrl + 'tree').then(resp => {