Add login/register logic

Signed-off-by: gearnode <bryan@frimin.fr>
This commit is contained in:
gearnode
2025-02-25 17:32:26 +01:00
parent 49c3807b4f
commit e9ae77a4a0
28 changed files with 2075 additions and 419 deletions

View File

@@ -0,0 +1,20 @@
import { Navigate, Outlet, useLocation } from "react-router";
import { useAuth } from "@/contexts/AuthContext";
export function ProtectedRoute() {
const { isAuthenticated, isLoading } = useAuth();
const location = useLocation();
// Show nothing while checking authentication
if (isLoading) {
return null;
}
// Redirect to login if not authenticated
if (!isAuthenticated) {
return <Navigate to="/login" replace state={{ from: location }} />;
}
// Render the protected content
return <Outlet />;
}

View File

@@ -1,5 +1,5 @@
/**
* @generated SignedSource<<578d66fa0d0065452d9fa64611b7cfda>>
* @generated SignedSource<<717a5c6c939c65b7e0790f84e2c41bcd>>
* @lightSyntaxTransform
* @nogrep
*/
@@ -72,7 +72,7 @@ return {
{
"alias": null,
"args": null,
"concreteType": "Viewer",
"concreteType": "User",
"kind": "LinkedField",
"name": "viewer",
"plural": false,
@@ -109,7 +109,7 @@ return {
{
"alias": null,
"args": null,
"concreteType": "Viewer",
"concreteType": "User",
"kind": "LinkedField",
"name": "viewer",
"plural": false,