summary refs log tree commit diff
path: root/assets/preload-plugins/loginRedirect.js
diff options
context:
space:
mode:
Diffstat (limited to 'assets/preload-plugins/loginRedirect.js')
-rw-r--r--assets/preload-plugins/loginRedirect.js27
1 files changed, 13 insertions, 14 deletions
diff --git a/assets/preload-plugins/loginRedirect.js b/assets/preload-plugins/loginRedirect.js
index c527d79d..cda4da44 100644
--- a/assets/preload-plugins/loginRedirect.js
+++ b/assets/preload-plugins/loginRedirect.js
@@ -1,17 +1,16 @@
-if (window.location.hostname == "127.0.0.1" || window.location.hostname == "localhost")
-	throw "disabling loginRedirect because localhost";
+if (window.location.hostname !== "127.0.0.1" && window.location.hostname !== "localhost") {
+	const redirectIfOnLogin = () => {
+		const path = window.location.pathname;
+		if (path == "/login" || path == "/register" || !localStorage.getItem("token")) {
+			window.location.pathname = "/login";
+			//window.location.reload();
+		}
+	};
 
-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 });
 
-const observer = new MutationObserver((mutations) => {
 	redirectIfOnLogin();
-});
-observer.observe(document, { subtree: true, childList: true });
-
-redirectIfOnLogin();
\ No newline at end of file
+}
\ No newline at end of file