fix login and show tasks
This commit is contained in:
parent
6ad423ae5c
commit
9b4eb8f7aa
2 changed files with 25 additions and 11 deletions
|
@ -95,8 +95,11 @@
|
|||
<script>
|
||||
const button_logout = document.getElementById("button-logout");
|
||||
const username = getCookie("username");
|
||||
const myHeaders = new Headers();
|
||||
myHeaders.append('username', username);
|
||||
const axiosConfig = {
|
||||
headers: {
|
||||
username: username,
|
||||
}
|
||||
};
|
||||
|
||||
const errorToastEl = document.getElementById('errorToast');
|
||||
const errorToastContent = document.getElementById('errorToastContent');
|
||||
|
@ -142,14 +145,13 @@
|
|||
}
|
||||
|
||||
async function userLoggedIn() {
|
||||
const response = await fetch("/auth/user", {method: 'GET', headers: myHeaders});
|
||||
const json = await response.json();
|
||||
if (json.logged_in === true) {
|
||||
const response = await axios.get("/auth/user", axiosConfig);
|
||||
if (response.data.logged_in === true) {
|
||||
document.getElementById("button-login").hidden = true;
|
||||
button_logout.hidden = false;
|
||||
document.getElementById("button-tasks").hidden = false;
|
||||
}
|
||||
return json.logged_in
|
||||
return response.data.logged_in
|
||||
}
|
||||
|
||||
async function logout() {
|
||||
|
|
Reference in a new issue