mirror of
https://dev.s-ul.net/Galexion/MaiMaiDXNet.git
synced 2024-11-24 08:50:10 +01:00
67 lines
3.0 KiB
Plaintext
67 lines
3.0 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>
|
|
const extId = localStorage.getItem('ext_id');
|
|
const luid = localStorage.getItem('luid');
|
|
|
|
if (extId === null || luid === null) {
|
|
console.log('User Data Not Detected! Please Sign In.');
|
|
} else {
|
|
console.log(`User Data Found! Redirecting to User Page.`);
|
|
window.location = "/user";
|
|
}
|
|
|
|
|
|
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> |