Created
December 13, 2025 17:54
-
-
Save davidystephenson/427a39e8ffe8533e8d09bb8469dd37d6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Observer the body tag of all html files. use validateLogIn function to verfy the login activity | |
| function validateLogIn () { | |
| const uName = document.getElementById('uName') | |
| const signOut = document.getElementById('signout') | |
| signOut.addEventListener('click', () => { | |
| sessionStorage.clear('login') | |
| window.location.href = '../sign-in.html' | |
| }) | |
| const sessionLogin = sessionStorage.getItem('login') | |
| if (!sessionLogin) { | |
| alert('You must sign in') | |
| window.location.href = '../sign-in.html' | |
| return | |
| } | |
| const localUser = localStorage.getItem('user') | |
| const user = JSON.parse(localUser) | |
| uName.innerHTML = user.username | |
| } | |
| // Add event listener to every sign out button in the header as asked in the problem statement. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment