Fix logout

This commit is contained in:
Reimar 2025-04-01 09:05:05 +02:00
parent c9155d582b
commit c42d2e3c16
Signed by: Reimar
GPG Key ID: 93549FA07F0AE268
10 changed files with 42 additions and 33 deletions

View File

@ -8,7 +8,6 @@
<link rel="stylesheet" href="/styles/auth.css">
<link rel="stylesheet" href="/styles/devices.css" />
<script defer type="module" src="/scripts/devices.js"></script>
<script defer type="module" src="/shared/utils.js"></script>
</head>
<body>
@ -16,9 +15,9 @@
<div class="topnav">
<a href="/home/index.html">Home</a>
<div style="display: flex; justify-content: flex-end;">
<a class="active" href="/devices/index.html">Devices</a>
<a href="/profile/index.html">Profile</a>
<span class="logoutContainer">
<a class="active" href="/devices">Devices</a>
<a href="/profile">Profile</a>
<span class="logout-container">
<img class="logout" src="/img/logout.png">
</span>
</div>

View File

@ -15,9 +15,9 @@
<div class="topnav">
<a class="active" href="/home/index.html">Home</a>
<div style="display: flex; justify-content: flex-end;">
<a href="/devices/index.html">Devices</a>
<a href="/profile/index.html">Profile</a>
<span class="logoutContainer">
<a href="/devices">Devices</a>
<a href="/profile">Profile</a>
<span class="logout-container">
<img class="logout" src="/img/logout.png">
</span>
</div>

View File

@ -4,8 +4,6 @@
<meta charset="UTF-8" />
<title>Temperature Alarm</title>
<link rel="stylesheet" href="/styles/frontpage.css">
<link rel="stylesheet" href="/styles/auth.css">
</head>
<body>
<main>

View File

@ -7,16 +7,15 @@
<link rel="stylesheet" href="/styles/auth.css">
<link rel="stylesheet" href="/styles/profile.css">
<script defer type="module" src="/scripts/profile.js"></script>
<script defer type="module" src="/shared/utils.js"></script>
</head>
<body>
<div id="container">
<div class="topnav">
<a href="/home/index.html">Home</a>
<div style="display: flex; justify-content: flex-end;">
<a href="/devices/index.html">Devices</a>
<a class="active" href="/profile/index.html">Profile</a>
<span class="logoutContainer">
<a href="/devices">Devices</a>
<a class="active" href="/profile">Profile</a>
<span class="logout-container">
<img class="logout" src="/img/logout.png">
</span>
</div>

View File

@ -1,5 +1,6 @@
import { getDevices, deleteDevice, update, add } from "./services/devices.service.js";
import { devices } from "../mockdata/devices.mockdata.js";
import { logout } from "../shared/utils.js";
getDevices().then(res => {
buildTable(res)
@ -88,3 +89,6 @@ document.getElementById("editbtn").onclick = () => {
window.location.reload();
}
};
document.querySelector(".logout-container").addEventListener("click", logout);

View File

@ -1,3 +1,4 @@
import { logout } from "../shared/utils.js";
import { getLogsOnDeviceId } from "./services/devices.service.js";
async function buildChart(data) {
@ -81,3 +82,6 @@ getLogsOnDeviceId(1)
document.getElementById("container").style.display = "none";
});
document.querySelector(".logout-container").addEventListener("click", logout);

View File

@ -1,4 +1,5 @@
import { profileData } from "../mockdata/profile.mockdata.js";
import { logout } from "../shared/utils.js";
import { get } from "./services/users.service.js";
import { update } from "./services/users.service.js";
import { updatePassword } from "./services/users.service.js";
@ -98,3 +99,6 @@ document.getElementById("PasswordForm").addEventListener("submit", function(even
}
});
});
document.querySelector(".logout-container").addEventListener("click", logout);

View File

@ -34,9 +34,9 @@ export async function request(method, path, body = null) {
});
}
document.querySelectorAll(".logoutContainer").forEach(closeBtn => {
closeBtn.onclick = () => {
localStorage.clear();
window.location.href = "/index.html";
};
});
export function logout() {
localStorage.removeItem("user");
document.cookie = "auth-token=";
window.location.href = "/";
}

View File

@ -6,9 +6,9 @@ body {
.topnav {
overflow: hidden;
background-color: #333;
}
.topnav a {
}
.topnav a {
height: 20px;
float: left;
color: #f2f2f2;
@ -16,9 +16,9 @@ body {
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
.topnav a:hover, .topnav span:hover {
}
.topnav a:hover, .topnav span:hover {
background-color: #ddd;
color: black;
cursor: pointer;
@ -66,15 +66,15 @@ button:hover {
margin-top: 0.5rem;
}
.logoutContainer{
display: flex;
justify-content: center;
align-items: center;
width: 50px;
.logout-container {
display: flex;
justify-content: center;
align-items: center;
width: 50px;
}
.logout{
width: 20px;
height: 24px;
.logout {
width: 20px;
height: 24px;
}

View File

@ -5,6 +5,7 @@
body {
font-family: sans-serif;
margin: 0;
}
main {