1
0
mirror of https://github.com/stonith404/pingvin-share.git synced 2024-09-21 04:20:37 +02:00
pingvin-share/frontend/src/pages/auth/signIn.tsx

28 lines
804 B
TypeScript
Raw Normal View History

import { LoadingOverlay } from "@mantine/core";
2022-04-25 15:15:17 +02:00
import { useRouter } from "next/router";
2022-12-01 23:07:49 +01:00
import SignInForm from "../../components/auth/SignInForm";
2022-04-28 15:31:37 +02:00
import Meta from "../../components/Meta";
import useUser from "../../hooks/user.hook";
2022-04-25 15:15:17 +02:00
const SignIn = () => {
const { user } = useUser();
const router = useRouter();
const redirectPath = (router.query.redirect as string) ?? "/upload";
// If the access token is expired, the middleware redirects to this page.
// If the refresh token is still valid, the user will be redirected to the home page.
if (user) {
router.replace(redirectPath);
return <LoadingOverlay overlayOpacity={1} visible />;
2022-04-25 15:15:17 +02:00
}
return (
<>
<Meta title="Sign In" />
<SignInForm redirectPath={redirectPath} />
</>
);
2022-04-25 15:15:17 +02:00
};
export default SignIn;