Skip sign in when signed in
This commit is contained in:
38
client/src/components/SignedInStatusVerifier.tsx
Normal file
38
client/src/components/SignedInStatusVerifier.tsx
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
import { useNavigate } from "react-router-dom";
|
||||||
|
import React, { useEffect, useState } from "react";
|
||||||
|
import { retrieveUserInformation } from "../security/users";
|
||||||
|
import { CircularProgress } from "@nextui-org/react";
|
||||||
|
|
||||||
|
export default function SignedInStatusVerifier({
|
||||||
|
children,
|
||||||
|
}: {
|
||||||
|
children: React.JSX.Element;
|
||||||
|
}) {
|
||||||
|
let navigate = useNavigate();
|
||||||
|
let [isLoading, setIsLoading] = useState(true);
|
||||||
|
useEffect(() => {
|
||||||
|
retrieveUserInformation()
|
||||||
|
.then((value) => {
|
||||||
|
if (value) navigate("/springboard");
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
setIsLoading(false);
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{!isLoading && <>{children}</>}
|
||||||
|
{isLoading && (
|
||||||
|
<div className="absolute inset-0 flex flex-col justify-center w-full h-full">
|
||||||
|
<div className="flex flex-row justify-center w-full h-full">
|
||||||
|
<CircularProgress
|
||||||
|
aria-label="Trying to sign in..."
|
||||||
|
label="Please wait..."
|
||||||
|
size="lg"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
import SignInModule from "../components/SignInModule";
|
import SignInModule from "../components/SignInModule";
|
||||||
import DefaultLayout from "../layouts/default";
|
import DefaultLayout from "../layouts/default";
|
||||||
|
import SignedInStatusVerifier from "../components/SignedInStatusVerifier";
|
||||||
|
|
||||||
export default function SignInPage() {
|
export default function SignInPage() {
|
||||||
return (
|
return (
|
||||||
|
<SignedInStatusVerifier>
|
||||||
<DefaultLayout>
|
<DefaultLayout>
|
||||||
<div className="flex flex-col h-full">
|
<div className="flex flex-col h-full">
|
||||||
<div className="flex flex-row h-full">
|
<div className="flex flex-row h-full">
|
||||||
@@ -32,5 +34,6 @@ export default function SignInPage() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</DefaultLayout>
|
</DefaultLayout>
|
||||||
|
</SignedInStatusVerifier>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
import SignUpModule from "../components/SignUpModule";
|
import SignUpModule from "../components/SignUpModule";
|
||||||
import DefaultLayout from "../layouts/default";
|
import DefaultLayout from "../layouts/default";
|
||||||
|
import SignedInStatusVerifier from "../components/SignedInStatusVerifier";
|
||||||
|
|
||||||
export default function SignUpPage() {
|
export default function SignUpPage() {
|
||||||
return (
|
return (
|
||||||
|
<SignedInStatusVerifier>
|
||||||
<DefaultLayout>
|
<DefaultLayout>
|
||||||
<div className="flex flex-col h-full">
|
<div className="flex flex-col h-full">
|
||||||
<div className="flex flex-row h-full">
|
<div className="flex flex-row h-full">
|
||||||
@@ -32,5 +34,6 @@ export default function SignUpPage() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</DefaultLayout>
|
</DefaultLayout>
|
||||||
|
</SignedInStatusVerifier>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user