-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauth.js
30 lines (28 loc) · 1009 Bytes
/
auth.js
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
// Check authentication status
function checkAuth() {
if (sessionStorage.getItem('isLoggedIn') !== 'true') {
window.location.href = 'login.html';
}
}
// Logout function
function logout() {
sessionStorage.removeItem('isLoggedIn');
window.location.href = 'logout-success.html'; // Redirect to the new logout success page
}
// Add logout button to the page
function addLogoutButton() {
const logoutBtn = document.createElement('button');
logoutBtn.textContent = 'Eject'; // Change the button text to "Eject"
logoutBtn.style.position = 'fixed';
logoutBtn.style.top = '10px';
logoutBtn.style.right = '10px';
logoutBtn.style.padding = '8px 16px';
logoutBtn.style.backgroundColor = '#e74c3c';
logoutBtn.style.color = 'white';
logoutBtn.style.border = 'none';
logoutBtn.style.borderRadius = '4px';
logoutBtn.style.cursor = 'pointer';
logoutBtn.style.zIndex = '1000';
logoutBtn.onclick = logout;
document.body.appendChild(logoutBtn);
}