2023-02-17 00:50:32 +01:00
|
|
|
<% var rootPath='../' ; %>
|
|
|
|
<%- include(rootPath + 'templates/header.ejs' ); %>
|
2023-02-17 07:33:10 +01:00
|
|
|
|
2023-02-17 00:50:32 +01:00
|
|
|
<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>
|
2023-02-17 07:33:10 +01:00
|
|
|
// Get the cookie string
|
|
|
|
const cookieString = document.cookie;
|
2023-02-17 00:50:32 +01:00
|
|
|
|
2023-02-17 07:33:10 +01:00
|
|
|
// 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.`);
|
2023-02-17 00:50:32 +01:00
|
|
|
window.location = "/user";
|
2023-02-17 07:33:10 +01:00
|
|
|
} else {
|
|
|
|
console.log('User Data Not Detected! Please Sign In.');
|
2023-02-17 00:50:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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)
|
2023-02-17 03:49:08 +01:00
|
|
|
// 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
|
2023-02-17 00:50:32 +01:00
|
|
|
window.location = "/user";
|
|
|
|
})
|
|
|
|
.catch(error => console.error(error));
|
|
|
|
});
|
|
|
|
</script> <!-- ToDo: Move this script to a seperate JS file.-->
|
|
|
|
</div>
|
|
|
|
</body>
|
|
|
|
|
|
|
|
</html>
|