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) { if (localStorage.getItem("token") !== null) {
document.getElementById("creator").style.display = "none";
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 = '';
}
})
} }
else { else {
document.getElementById("creator").style.display = ""; 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> <script type="text/javascript" src="app.js"></script>
</head> </head>
<body onload="renderTournaments();logoutVisibility(); loginVisibility(); creatorVisibility();"> <body onload="renderTournaments();logoutVisibility(); loginVisibility(); checkRole();">
<header> <header>
<div class="logoBox"> <div class="logoBox">
<a class="header_link" href="./index.html"><img class="logo" src="./_global/logo.svg" alt="Logo error"></a> <a class="header_link" href="./index.html"><img class="logo" src="./_global/logo.svg" alt="Logo error"></a>