-
Notifications
You must be signed in to change notification settings - Fork 0
/
dashboard.html
60 lines (53 loc) · 1.95 KB
/
dashboard.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dashboard</title>
<link rel="stylesheet" href="dashboard.css">
</head>
<body>
<div class="wrapper">
<header>
<h1>Dashboard</h1>
<div>
<a href="gptcoach.html" class="back-button">GPTCoach</a>
<a href="index.html" class="back-button">Form</a>
<a href="weight.html" class="back-button">Weight</a>
<a href="entries.html" class="back-button">Entries</a>
<button id="logoutButton" class="back-button">Logout</button>
</div>
</header>
<div class="container">
<!-- Add your dashboard content here -->
</div>
<footer class="footer">
<p>Developed by Ruben Triegaardt</p>
</footer>
</div>
<script>
// Check if the user is authenticated
if (!localStorage.getItem('authenticated')) {
window.location.href = 'login.html';
}
// Auto logout after 1 hour
const loginTime = localStorage.getItem('loginTime');
if (loginTime && (Date.now() - parseInt(loginTime)) > 3600000) { // 1 hour in milliseconds
localStorage.removeItem('authenticated');
localStorage.removeItem('loginTime');
alert('Session expired. Please log in again.');
window.location.href = 'login.html';
}
// Logout button functionality
const logoutButton = document.getElementById('logoutButton');
if (logoutButton) {
logoutButton.addEventListener('click', () => {
localStorage.removeItem('authenticated');
localStorage.removeItem('loginTime');
alert('Logged out successfully.');
window.location.href = 'login.html';
});
}
</script>
</body>
</html>