|
|
|
@ -1,18 +1,21 @@
@@ -1,18 +1,21 @@
|
|
|
|
|
var user = null; |
|
|
|
|
async function handleUser(response){ |
|
|
|
|
|
|
|
|
|
function handleUser(response){ |
|
|
|
|
if (response.status == UNAUTHORIZED) { |
|
|
|
|
login(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (response.ok){ |
|
|
|
|
user = await response.json(); |
|
|
|
|
fetch(web+"/navigation.html").then(handleNavigation); |
|
|
|
|
response.json().then(u => { |
|
|
|
|
user = u; |
|
|
|
|
fetch(web+"/navigation.html",{credentials:'include'}).then(handleNavigation); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async function handleNavigation(response){ |
|
|
|
|
function handleNavigation(response){ |
|
|
|
|
if (response.ok){ |
|
|
|
|
var content = await response.text(); |
|
|
|
|
response.text().then(content => { |
|
|
|
|
var nav = document.getElementsByTagName('nav')[0]; |
|
|
|
|
nav.innerHTML = content; |
|
|
|
|
var links = nav.getElementsByTagName('a'); |
|
|
|
@ -21,7 +24,11 @@ async function handleNavigation(response){
@@ -21,7 +24,11 @@ async function handleNavigation(response){
|
|
|
|
|
var clazz = link.hasAttribute('class') ? link.getAttribute("class") : null; |
|
|
|
|
if (clazz != null && !user.permissions.includes(clazz)) nav.removeChild(link); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fetch(user_controller+"/",{method:'POST'}).then(handleUser); |
|
|
|
|
fetch(user_controller+"/",{ |
|
|
|
|
method:'POST', |
|
|
|
|
credentials:'include' |
|
|
|
|
}).then(handleUser); |
|
|
|
|