1
0
mirror of https://dev.s-ul.net/Galexion/MaiMaiDXNet.git synced 2024-11-24 05:40:11 +01:00

fixed bug where index.ejs wouldnt send people to /user if they were already signed in, documented stuff

This commit is contained in:
Galexion 2023-02-17 01:33:10 -05:00
parent a8d06a4ae1
commit 3a16706814
2 changed files with 29 additions and 11 deletions

View File

@ -13,14 +13,32 @@
</form>
<script>
const extId = localStorage.getItem('ext_id');
const luid = localStorage.getItem('luid');
// Get the cookie string
const cookieString = document.cookie;
if (extId === null || luid === null) {
console.log('User Data Not Detected! Please Sign In.');
} else {
console.log(`User Data Found! Redirecting to User Page.`);
// 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.');
}

View File

@ -54,7 +54,7 @@
}
}
// Use the values as needed
// Sends user to the sign in page if they aren't already signed in to the website.
if (ext_id2 && luid2) {
console.log(`ext_id: ${ext_id2}, luid: ${luid2}`);
@ -64,7 +64,7 @@
}
</script>
<% if(userdata.icon_id===10) { %>
<% if(userdata.icon_id===10) { %> <!-- If the user icon id is set to 10, it's a custom image and you need to grab the image that the user uploaded. -->
<img id="user-image" src="" alt="User Image">
<script>
@ -72,14 +72,14 @@
userImage.src = "images/" + ext_id2 + '-up.jpg';
</script>
<% } else {%>
<% } else {%> <!-- If Not, use the userdata.icon_id variable to find which icon you need. -->
<img id="user-image" src="" alt="User Image">
<script data-userdata="<%=JSON.stringify(userdata)%>">
const userdata = JSON.parse(document.currentScript.getAttribute('data-userdata'));
const userImage = document.getElementById('user-image');
const UI_Icon = userdata.icon_id
function padNumber(num, size) {
function padNumber(num, size) { // pad the number because haha game weird
var s = num + "";
while (s.length < size) s = "0" + s;
return s;