fix: 🐛 Now user and unlogged user cant see ,,tworzenie turnieju"

This commit is contained in:
Arek 2022-06-14 13:11:09 +02:00
parent 5ce2883a53
commit 6392fea39c
2 changed files with 33 additions and 6 deletions

View File

@ -64,12 +64,39 @@ function loginVisibility() {
}
}
function createVisibility() {
function checkRole() {
if (localStorage.getItem("token") !== null) {
fetch('https://dragonmaster.pl/inz/user', {
headers: {
Authorization: ("Bearer " + localStorage.getItem("token"))
}
})
.then(res => res.json())
.then(json => {
if (json['role'] == '1') {
document.getElementById("creator").style.display = "none";
}
else {
document.getElementById("creator").style.display = "";
document.getElementById("creator").style.display = '';
}
})
}
else {
document.getElementById("creator").style.display = "none";
}
}
}
// function creatorVisibility() {
// if (localStorage.getItem("token") == null) {
// document.getElementById("creator").style.display = "none";
// }
// else if (checkRole()) {
// document.getElementById("creator").style.display = "none";
// }
// else {
// document.getElementById("creator").style.display = "";
// }
// }

View File

@ -10,7 +10,7 @@
<script type="text/javascript" src="app.js"></script>
</head>
<body onload="renderTournaments();logoutVisibility(); loginVisibility(); creatorVisibility();">
<body onload="renderTournaments();logoutVisibility(); loginVisibility(); checkRole();">
<header>
<div class="logoBox">
<a class="header_link" href="./index.html"><img class="logo" src="./_global/logo.svg" alt="Logo error"></a>