Add: redirect logged in users to / from login page
This commit is contained in:
parent
6be77a6859
commit
97940c188a
1 changed files with 7 additions and 0 deletions
|
@ -23,6 +23,13 @@ export function LoginForm({
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
|
// Redirect if already logged in
|
||||||
|
useEffect(() => {
|
||||||
|
const token = localStorage.getItem("access_token");
|
||||||
|
if (token) {
|
||||||
|
navigate("/", { replace: true }); // Redirect to homepage
|
||||||
|
}
|
||||||
|
}, [navigate]);
|
||||||
|
|
||||||
const handelLogin = async (e) => {
|
const handelLogin = async (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
Loading…
Add table
Reference in a new issue