1
0
mirror of https://dev.s-ul.net/Galexion/MaiMaiDXNet.git synced 2024-11-28 04:30:50 +01:00
MaiMaiDXNet/views/user.ejs

65 lines
2.4 KiB
Plaintext

<% var rootPath='../' ; %>
<%- include(rootPath + 'templates/header.ejs' ); %>
<h1>Yo! Welcome Back ${User}!</h1>
<button id="clear-storage-btn">Sign Out</button>
<script>
const extId = localStorage.getItem('ext_id');
const luid = localStorage.getItem('luid');
const clearStorageBtn = document.getElementById('clear-storage-btn');
clearStorageBtn.addEventListener('click', () => {
// Remove the cookies
function removeCookies() {
// Set the expiration date to a date in the past
const expirationDate = new Date(0).toUTCString();
// Set the ext_id cookie to expire
document.cookie = `ext_id=; expires=${expirationDate}`;
// Set the luid cookie to expire
document.cookie = `luid=; expires=${expirationDate}`;
// Set the aime_card_id cookie to expire
document.cookie = `aime_card_id=; expires=${expirationDate}`;
}
// Example usage
removeCookies();
console.log('Local storage cleared.');
window.location = "/";
});
// Get the cookie string
const cookieString = document.cookie;
// Parse the cookie string and extract the values
const cookies = cookieString.split(';');
let ext_id2, luid2;
for (let i = 0; i < cookies.length; i++) {
const cookie = cookies[i].trim();
const cookieParts = cookie.split('=');
if (cookieParts[0] === 'ext_id') {
ext_id2 = cookieParts[1];
}
if (cookieParts[0] === 'luid') {
luid2 = cookieParts[1];
}
}
// Use the values as needed
if (ext_id2 && luid2) {
console.log(`ext_id: ${ext_id2}, luid: ${luid2}`);
} else {
console.log('User Data Not Detected! Please Sign In.');
window.location = "/";
}
</script>
<details>
<summary>Developer Only Information</summary>
For Development purposes only, send statistics found in this menu when encontering UI Errors.
</details>