Skip to content

Commit

Permalink
Merge pull request #106 from aadibhat09/main
Browse files Browse the repository at this point in the history
log out button clears local storage
  • Loading branch information
aadibhat09 authored Nov 4, 2024
2 parents f1922b1 + 216d06a commit bba80c8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions navigation/rate_and_relate/instabox/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,11 @@ author: Aadi, Aaditya, Aditya, Kanhay
<!-- Save Changes button -->
<button class="save-btn" onclick="updateInfo()">Save Changes</button>
<!-- Log Out button -->
<button class="logout-btn">Log Out</button>
<button class="logout-btn" onclick="logOut()">Log Out</button>
</div>
</div>
<script>
// Updates username or password if current password is entered
function updateInfo() {
const username = document.getElementById("username").value;
const newPassword = document.getElementById("new-password").value;
Expand All @@ -166,7 +167,7 @@ author: Aadi, Aaditya, Aditya, Kanhay
return;
}
if (username != "") {
localStorage.setItem("username", username);
localStorage.setItem("username", username.trim());
usernameUpdated = true;
}
if (newPassword === "" && confirmPassword === "") {
Expand All @@ -187,5 +188,12 @@ author: Aadi, Aaditya, Aditya, Kanhay
}
}
}
// Clear saved data and reload page
function logOut() {
const usernameString = localStorage.getItem("username");
localStorage.clear();
location.reload();
alert("You have been logged out from " + usernameString + ".");
}
</script>
</body>

0 comments on commit bba80c8

Please sign in to comment.