summary refs log tree commit diff
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-09-26 13:04:55 +1000
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-09-26 13:04:55 +1000
commitd96d6681231c8f4ac1e19b068535ae09a0ce2c5c (patch)
treec0c56951bd987e1edf219c17045ccc75bec8ac6d
parentRearrange assets a bit, fix anything that uses assets folder (diff)
downloadserver-d96d6681231c8f4ac1e19b068535ae09a0ce2c5c.tar.xz
Bring back loginRedirect but fix it. Also move some assets out of public
-rw-r--r--assets/openapi.json (renamed from assets/public/openapi.json)0
-rw-r--r--assets/preload-plugins/loginRedirect.js17
-rw-r--r--assets/schemas.json (renamed from assets/public/schemas.json)0
3 files changed, 17 insertions, 0 deletions
diff --git a/assets/public/openapi.json b/assets/openapi.json
index a8a657b2..a8a657b2 100644
--- a/assets/public/openapi.json
+++ b/assets/openapi.json
diff --git a/assets/preload-plugins/loginRedirect.js b/assets/preload-plugins/loginRedirect.js
new file mode 100644
index 00000000..695515b3
--- /dev/null
+++ b/assets/preload-plugins/loginRedirect.js
@@ -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();
\ No newline at end of file
diff --git a/assets/public/schemas.json b/assets/schemas.json
index 24acc85f..24acc85f 100644
--- a/assets/public/schemas.json
+++ b/assets/schemas.json