1
0
Fork 0

UI detection of JWT token in case of server restart or upgrade (#3001)

* UI detection of JWT token in case of server restart or upgrade

* added jwt verify check if response is unauthorized
This commit is contained in:
Heiko 2017-08-10 22:12:45 +02:00 committed by Frank Celler
parent 897e2d6467
commit e06c85886e
4 changed files with 31 additions and 3 deletions

View File

@ -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

View File

@ -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) {

View File

@ -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();

View File

@ -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);
}
});
};