mirror of
https://dev.s-ul.net/Galexion/MaiMaiDXNet.git
synced 2024-11-28 01:00:49 +01:00
85 lines
3.6 KiB
Plaintext
85 lines
3.6 KiB
Plaintext
<% var rootPath='../' ; %>
|
|
<%- include(rootPath + 'templates/header.ejs' ); %>
|
|
|
|
<div id="loginContent">
|
|
<h1>MaiMaiDX.Net</h1>
|
|
<h5>Total Users Registered: <%= params.totalUsers %>
|
|
</h5>
|
|
|
|
<h4>Please Input your 20 Digit Access Code.</h4>
|
|
<form id="myForm">
|
|
<input type="text" name="myInput" maxlength="20" placeholder="0000011111222223333344444" required>
|
|
<button type="submit">Submit</button>
|
|
</form>
|
|
|
|
<script>
|
|
// 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];
|
|
}
|
|
}
|
|
|
|
// Sends user to User Page if already signed in
|
|
if (ext_id2 && luid2) {
|
|
console.log(`User Data Detected, sending to user page.`);
|
|
window.location = "/user";
|
|
} else {
|
|
console.log('User Data Not Detected! Please Sign In.');
|
|
}
|
|
|
|
|
|
const form = document.getElementById("myForm");
|
|
form.addEventListener("submit", function (event) {
|
|
event.preventDefault(); // Prevent the default form submission behavior
|
|
|
|
const input = document.getElementsByName("myInput")[0].value;
|
|
const url = "/api/getExtId"; // Replace with your API endpoint URL
|
|
|
|
// Send the input data to the API endpoint using fetch
|
|
fetch(url, {
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json"
|
|
},
|
|
body: JSON.stringify({ input: input })
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
console.log(data)
|
|
let releventData = { luid: data.data.luid, ext_id: data.data.ext_id }
|
|
console.log(releventData)
|
|
// Set the cookie expiration to 7 days from now
|
|
const expirationDate = new Date(Date.now() + 7 * 24 * 60 * 60 * 1000);
|
|
// Set the ext_id cookie
|
|
document.cookie = `ext_id=${data.data.ext_id}; expires=${expirationDate.toUTCString()}`;
|
|
|
|
// Set the luid cookie
|
|
document.cookie = `luid=${data.data.luid}; expires=${expirationDate.toUTCString()}`;
|
|
console.log(data.data.id)
|
|
// Set the aime_card_id cookie
|
|
document.cookie = `aime_card_id=${data.data.id.toString()}; expires=${expirationDate.toUTCString()}`;
|
|
|
|
// Set the cookie
|
|
window.location = "/user";
|
|
})
|
|
.catch(error => console.error(error));
|
|
});
|
|
</script> <!-- ToDo: Move this script to a seperate JS file.-->
|
|
</div>
|
|
</body>
|
|
|
|
</html> |