Bring back loginRedirect but fix it. Also move some assets out of public

This commit is contained in:
Madeline 2022-09-26 13:04:55 +10:00
parent 9c688527ec
commit 4cdb547f76
3 changed files with 17 additions and 0 deletions

View File

@ -0,0 +1,17 @@
if (window.location.hostname == "127.0.0.1" || window.location.hostname == "localhost")
throw "disabling loginRedirect because localhost";
const redirectIfOnLogin = () => {
const path = window.location.pathname;
if (path == "/login" || path == "/register" || !localStorage.getItem("token")) {
window.location.pathname = "/login";
window.location.reload();
}
};
const observer = new MutationObserver((mutations) => {
redirectIfOnLogin();
});
observer.observe(document, { subtree: true, childList: true });
redirectIfOnLogin();