webapp.check-auth.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of broker-admin Show documentation
Show all versions of broker-admin Show documentation
Administration frontend for the AKTIN broker and aggregator
var rest_base='../..';
function updateAuthStatus(onSuccess){
$.ajax({
type: 'GET',
url: rest_base+'/auth/status',
success: function(data) {
// TODO remember token expiration date
onSuccess();
},
error: function(xhr, s, e){
console.log('Session abgelaufen: '+s);
window.location.replace('login.html');
},
dataType: "xml"
});
}
function getNodes(success, error){
return $.ajax({
type: 'GET',
url: rest_base+'/broker/node',
success: function(data) {
var a = [];
var nodes = data.getElementsByTagNameNS('http://aktin.org/ns/exchange','node');
for( var i=0; i ',{href:'nodes.html#'+this.id, text:this.cn, title:this.dn});
},
seen: nodes[i].childNodes[2].innerHTML,
websocket: nodes[i].childNodes[3].innerHTML
});
}
success(a);
},
error: error,
dataType: "xml"
});
}
$(document).ready(function(){
// check if cookie is set
var token = Cookies.get('token');
if( token ){
$.ajaxSetup({beforeSend: function (xhr){
xhr.setRequestHeader("Authorization","Bearer "+token);
}});
// cookie still valid?
updateAuthStatus(init);
}else{
// no token cookie, redirect to login
window.location.replace('login.html');
}
});