diff --git a/frontend/app.js b/frontend/app.js index f9d9699..2ae59b2 100644 --- a/frontend/app.js +++ b/frontend/app.js @@ -64,12 +64,39 @@ function loginVisibility() { } } -function createVisibility() { + +function checkRole() { 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 { - document.getElementById("creator").style.display = ""; - + document.getElementById("creator").style.display = "none"; } -} \ No newline at end of file + +} + +// 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 = ""; +// } +// } \ No newline at end of file diff --git a/frontend/index.html b/frontend/index.html index 3cb42dd..e9e5376 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -10,7 +10,7 @@ - +