You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
606 B
Plaintext

11 months ago
import { Fragment } from "react";
import { userStore } from "../store/userStore";
import { Navigate } from "react-router-dom";
export function RequireAuth({ children }: { children: JSX.Element }) {
const token = userStore.token;
return (
<Fragment>
{!token ? <Navigate to="/login" replace={true} /> : children}
</Fragment>
)
}
export function LoginPageGuard({ children }: { children: JSX.Element }) {
const token = userStore.token;
return (
<Fragment>
{token ? <Navigate to="/" replace={true} /> : children}
</Fragment>
)
}