feat: kick out users who arent signed in
This commit is contained in:
parent
901ef26440
commit
50a36e2db4
4 changed files with 41 additions and 12 deletions
|
|
@ -144,8 +144,6 @@ window.loadHeader(async function(headerContainer) {
|
|||
const udemaeKey = equipped.Udemae !== undefined ? String(equipped.Udemae) : String(finalData.Udemae || "");
|
||||
const rankGrade = udemaeMap[udemaeKey] || (udemaeKey !== "undefined" && udemaeKey !== "" ? udemaeKey : "--");
|
||||
|
||||
// do this bs so splahoon will be happy
|
||||
// im glad i can make people happy with a 2 liner though.. C:
|
||||
const renderImg = (src, className) => {
|
||||
const fallback = className.includes('weapon') || className.includes('gear') ? 'this.src="/assets/weapons/NotFound^w.png"' : 'this.src="../assets/ability/ParameterIcon^q.png"';
|
||||
return src ? `<img class="${className}" src="${src}" onerror='${fallback}' />` : '';
|
||||
|
|
@ -241,15 +239,24 @@ window.loadHeader(async function(headerContainer) {
|
|||
}
|
||||
|
||||
try {
|
||||
const handleFetch = async (url) => {
|
||||
const res = await fetch(url, { credentials: 'include' });
|
||||
if (res.redirected) {
|
||||
window.location.href = res.url;
|
||||
return {};
|
||||
}
|
||||
return res.ok ? res.json() : {};
|
||||
};
|
||||
|
||||
const [profileRes, equipRes, historyRes] = await Promise.all([
|
||||
fetch("/api/v1/me", { credentials: 'include' }).then(res => res.ok ? res.json() : {}),
|
||||
fetch("/api/v1/me/equipment", { credentials: 'include' }).then(res => res.ok ? res.json() : {}),
|
||||
fetch("/api/v1/me/equipment/history", { credentials: 'include' }).then(res => res.ok ? res.json() : [])
|
||||
handleFetch("/api/v1/me"),
|
||||
handleFetch("/api/v1/me/equipment"),
|
||||
handleFetch("/api/v1/me/equipment/history")
|
||||
]);
|
||||
|
||||
await renderData(profileRes, false);
|
||||
await renderData(equipRes, false);
|
||||
await renderData({ history: historyRes }, false);
|
||||
await renderData({ history: Array.isArray(historyRes) ? historyRes : [] }, false);
|
||||
sessionStorage.setItem('user_cache', JSON.stringify(combinedData));
|
||||
} catch (err) {
|
||||
if (cacheFound) {
|
||||
|
|
|
|||
|
|
@ -65,8 +65,15 @@ window.loadHeader(function(headerContainer) {
|
|||
if (cached) renderData(JSON.parse(cached));
|
||||
|
||||
fetch("/api/v1/me", { credentials: 'include' })
|
||||
.then(res => res.ok ? res.json() : Promise.reject(res))
|
||||
.then(res => {
|
||||
if (res.redirected) {
|
||||
window.location.href = res.url;
|
||||
return;
|
||||
}
|
||||
return res.ok ? res.json() : Promise.reject(res);
|
||||
})
|
||||
.then(data => {
|
||||
if (!data) return;
|
||||
sessionStorage.setItem('user_cache', JSON.stringify(data));
|
||||
renderData(data);
|
||||
})
|
||||
|
|
|
|||
|
|
@ -67,8 +67,15 @@ window.loadHeader(function(headerContainer) {
|
|||
if (cached) renderData(JSON.parse(cached));
|
||||
|
||||
fetch("/api/v1/me", { credentials: 'include' })
|
||||
.then(res => res.ok ? res.json() : Promise.reject(res))
|
||||
.then(res => {
|
||||
if (res.redirected) {
|
||||
window.location.href = res.url;
|
||||
return;
|
||||
}
|
||||
return res.ok ? res.json() : Promise.reject(res);
|
||||
})
|
||||
.then(data => {
|
||||
if (!data) return;
|
||||
sessionStorage.setItem('user_cache', JSON.stringify(data));
|
||||
renderData(data);
|
||||
})
|
||||
|
|
|
|||
|
|
@ -78,13 +78,21 @@ window.loadHeader(async function(headerContainer) {
|
|||
}
|
||||
|
||||
try {
|
||||
const [profileRes, rotationsData] = await Promise.all([
|
||||
fetch("/api/v1/me", { credentials: 'include' }).then(res => res.ok ? res.json() : {}),
|
||||
const [profileRes] = await Promise.all([
|
||||
fetch("/api/v1/me", { credentials: 'include' }).then(res => {
|
||||
if (res.redirected) {
|
||||
window.location.href = res.url;
|
||||
return {};
|
||||
}
|
||||
return res.ok ? res.json() : {};
|
||||
}),
|
||||
renderStages()
|
||||
]);
|
||||
|
||||
await renderData(profileRes);
|
||||
sessionStorage.setItem('user_cache', JSON.stringify(profileRes));
|
||||
if (profileRes && Object.keys(profileRes).length > 0) {
|
||||
await renderData(profileRes);
|
||||
sessionStorage.setItem('user_cache', JSON.stringify(profileRes));
|
||||
}
|
||||
} catch (err) {
|
||||
if (!cacheReady) {
|
||||
const nameEl = document.getElementById('mii-name');
|
||||
|
|
|
|||
Loading…
Reference in a new issue