Redirect authenticated users away from login/setup pages
Some checks failed
Build MIPS Binary / build (push) Failing after 3m27s
Some checks failed
Build MIPS Binary / build (push) Failing after 3m27s
This commit is contained in:
@@ -69,6 +69,14 @@ pub fn App() -> impl IntoView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
set_is_authenticated.set(true);
|
set_is_authenticated.set(true);
|
||||||
|
|
||||||
|
// If user is already authenticated but on login/setup page, redirect to home
|
||||||
|
let pathname = window().location().pathname().unwrap_or_default();
|
||||||
|
if pathname == "/login" || pathname == "/setup" {
|
||||||
|
logging::log!("Already authenticated, redirecting to home");
|
||||||
|
let navigate = use_navigate();
|
||||||
|
navigate("/", Default::default());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
logging::log!("Not authenticated, redirecting to /login");
|
logging::log!("Not authenticated, redirecting to /login");
|
||||||
let navigate = use_navigate();
|
let navigate = use_navigate();
|
||||||
@@ -80,7 +88,6 @@ pub fn App() -> impl IntoView {
|
|||||||
}
|
}
|
||||||
Err(e) => logging::error!("Network error checking auth status: {}", e),
|
Err(e) => logging::error!("Network error checking auth status: {}", e),
|
||||||
}
|
}
|
||||||
|
|
||||||
set_is_loading.set(false);
|
set_is_loading.set(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user