mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-05 18:32:33 +01:00
Bring back loginRedirect but fix it. Also move some assets out of public
This commit is contained in:
parent
fa89b18d95
commit
d96d668123
17
assets/preload-plugins/loginRedirect.js
Normal file
17
assets/preload-plugins/loginRedirect.js
Normal 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();
|
Loading…
Reference in New Issue
Block a user