From 879bfa7391fef0afd3c9980ac993d39ab40b5609 Mon Sep 17 00:00:00 2001 From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> Date: Sat, 9 Jul 2022 18:58:17 +1000 Subject: [PATCH] Redirect to custom login page when client navigates to /login or /register --- api/assets/preload-plugins/loginRedirect.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 api/assets/preload-plugins/loginRedirect.js diff --git a/api/assets/preload-plugins/loginRedirect.js b/api/assets/preload-plugins/loginRedirect.js new file mode 100644 index 00000000..895536ef --- /dev/null +++ b/api/assets/preload-plugins/loginRedirect.js @@ -0,0 +1,13 @@ +const redirectIfOnLogin = () => { + const path = window.location.pathname; + if (path == "/login" || path == "/register") { + window.location.reload(); + } +} + +const observer = new MutationObserver((mutations) => { + redirectIfOnLogin(); +}); +observer.observe(document, { subtree: true, childList: true }) + +redirectIfOnLogin(); \ No newline at end of file