diff --git a/CHANGELOG b/CHANGELOG index 0fcb59e05a..4ea36a781c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,8 @@ devel ----- +* fixed issue #2835: UI detection of JWT token in case of server restart or upgrade + * upgrade jemalloc version to 5.0.1 * fixed docs for issue #2968 diff --git a/js/apps/system/_admin/aardvark/APP/frontend/js/arango/arango.js b/js/apps/system/_admin/aardvark/APP/frontend/js/arango/arango.js index f27d40a0d5..c530b68373 100644 --- a/js/apps/system/_admin/aardvark/APP/frontend/js/arango/arango.js +++ b/js/apps/system/_admin/aardvark/APP/frontend/js/arango/arango.js @@ -95,6 +95,22 @@ localStorage.setItem('jwtUser', username); }, + checkJwt: function () { + $.ajax({ + type: 'GET', + cache: false, + url: arangoHelper.databaseUrl('/_api/version'), + contentType: 'application/json', + processData: false, + async: true, + error: function (jqXHR) { + if (jqXHR.status === 401) { + window.App.navigate('login', {trigger: true}); + } + } + }); + }, + getCoordinatorShortName: function (id) { var shortName; if (window.clusterHealth) { diff --git a/js/apps/system/_admin/aardvark/APP/frontend/js/routers/startApp.js b/js/apps/system/_admin/aardvark/APP/frontend/js/routers/startApp.js index f8c5086ab8..1d831ade00 100644 --- a/js/apps/system/_admin/aardvark/APP/frontend/js/routers/startApp.js +++ b/js/apps/system/_admin/aardvark/APP/frontend/js/routers/startApp.js @@ -1,5 +1,5 @@ /* jshint unused: false */ -/* global window, $, Backbone, document */ +/* global window, $, Backbone, document, arangoHelper */ (function () { 'use strict'; @@ -12,6 +12,15 @@ } }); + $.ajaxSetup({ + error: function (x, status, error) { + if (x.status === 401) { + // session might be expired. check if jwt is still valid + arangoHelper.checkJwt(); + } + } + }); + $(document).ready(function () { window.App = new window.Router(); Backbone.history.start(); diff --git a/js/apps/system/_admin/aardvark/APP/frontend/js/views/loginView.js b/js/apps/system/_admin/aardvark/APP/frontend/js/views/loginView.js index 547172aaf1..e7ce263dc7 100644 --- a/js/apps/system/_admin/aardvark/APP/frontend/js/views/loginView.js +++ b/js/apps/system/_admin/aardvark/APP/frontend/js/views/loginView.js @@ -1,6 +1,6 @@ /* jshint browser: true */ /* jshint unused: false */ -/* global Backbone, document, _, arangoHelper, window, setTimeout, $, templateEngine, frontendConfig */ +/* global Backbone, location, document, _, arangoHelper, window, setTimeout, $, templateEngine, frontendConfig */ (function () { 'use strict'; @@ -65,7 +65,8 @@ if (errCallback) { errCallback(); } else { - console.log('could not fetch user db data'); + // existing jwt login is not valid anymore => reload + location.reload(true); } }); };