mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-10 07:25:35 +00:00
refacto: create src dir & change project indentation to 2 spaces
This commit is contained in:
27
src/components/AuthRequired.tsx
Normal file
27
src/components/AuthRequired.tsx
Normal file
@@ -0,0 +1,27 @@
|
||||
import { useSession } from "next-auth/react";
|
||||
import { useRouter } from "next/router";
|
||||
|
||||
export default function Auth({ children }) {
|
||||
const router = useRouter();
|
||||
const { status } = useSession({
|
||||
required: true,
|
||||
onUnauthenticated: () =>
|
||||
router.push(
|
||||
`/signin?info=${encodeURI(
|
||||
"Vous devez être connecté pour accéder à cette page"
|
||||
)}`
|
||||
),
|
||||
});
|
||||
|
||||
if (status === "loading") {
|
||||
return (
|
||||
<div className="App" style={{ alignItems: "center" }}>
|
||||
<p style={{ height: "fit-content" }}>
|
||||
Chargement de la session en cours
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return children;
|
||||
}
|
||||
Reference in New Issue
Block a user