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 devel
----- -----
* fixed issue #2835: UI detection of JWT token in case of server restart or upgrade
* upgrade jemalloc version to 5.0.1 * upgrade jemalloc version to 5.0.1
* fixed docs for issue #2968 * fixed docs for issue #2968

View File

@ -95,6 +95,22 @@
localStorage.setItem('jwtUser', username); 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) { getCoordinatorShortName: function (id) {
var shortName; var shortName;
if (window.clusterHealth) { if (window.clusterHealth) {

View File

@ -1,5 +1,5 @@
/* jshint unused: false */ /* jshint unused: false */
/* global window, $, Backbone, document */ /* global window, $, Backbone, document, arangoHelper */
(function () { (function () {
'use strict'; '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 () { $(document).ready(function () {
window.App = new window.Router(); window.App = new window.Router();
Backbone.history.start(); Backbone.history.start();

View File

@ -1,6 +1,6 @@
/* jshint browser: true */ /* jshint browser: true */
/* jshint unused: false */ /* jshint unused: false */
/* global Backbone, document, _, arangoHelper, window, setTimeout, $, templateEngine, frontendConfig */ /* global Backbone, location, document, _, arangoHelper, window, setTimeout, $, templateEngine, frontendConfig */
(function () { (function () {
'use strict'; 'use strict';
@ -65,7 +65,8 @@
if (errCallback) { if (errCallback) {
errCallback(); errCallback();
} else { } else {
console.log('could not fetch user db data'); // existing jwt login is not valid anymore => reload
location.reload(true);
} }
}); });
}; };