Build base web
This commit is contained in:
14
virtweb_frontend/src/routes/NotFound.tsx
Normal file
14
virtweb_frontend/src/routes/NotFound.tsx
Normal file
@ -0,0 +1,14 @@
|
||||
import { Button } from "@mui/material";
|
||||
import { RouterLink } from "../widgets/RouterLink";
|
||||
|
||||
export function NotFoundRoute(): React.ReactElement {
|
||||
return (
|
||||
<div style={{ textAlign: "center" }}>
|
||||
<h1>Page non trouvée !</h1>
|
||||
<p>La page que vous demandez n'a pas été trouvée !</p>
|
||||
<RouterLink to="/">
|
||||
<Button>Retour à l'accueil</Button>
|
||||
</RouterLink>
|
||||
</div>
|
||||
);
|
||||
}
|
3
virtweb_frontend/src/routes/auth/LoginRoute.tsx
Normal file
3
virtweb_frontend/src/routes/auth/LoginRoute.tsx
Normal file
@ -0,0 +1,3 @@
|
||||
export function LoginRoute() {
|
||||
return <></>;
|
||||
}
|
53
virtweb_frontend/src/routes/auth/OIDCCbRoute.tsx
Normal file
53
virtweb_frontend/src/routes/auth/OIDCCbRoute.tsx
Normal file
@ -0,0 +1,53 @@
|
||||
import { CircularProgress } from "@mui/material";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useNavigate, useSearchParams } from "react-router-dom";
|
||||
import { AuthApi } from "../../api/AuthApi";
|
||||
import { useAuth } from "../../App";
|
||||
import { AuthSingleMessage } from "../../widgets/AuthSingleMessage";
|
||||
|
||||
/**
|
||||
* OpenID login callback route
|
||||
*/
|
||||
export function OIDCCbRoute(): React.ReactElement {
|
||||
const auth = useAuth();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const [error, setError] = useState(false);
|
||||
|
||||
const [searchParams] = useSearchParams();
|
||||
const code = searchParams.get("code");
|
||||
const state = searchParams.get("state");
|
||||
|
||||
const count = useRef("");
|
||||
|
||||
useEffect(() => {
|
||||
const load = async () => {
|
||||
try {
|
||||
if (count.current === code) {
|
||||
return;
|
||||
}
|
||||
count.current = code!;
|
||||
|
||||
await AuthApi.FinishOpenIDLogin(code!, state!);
|
||||
navigate("/");
|
||||
auth.setSignedIn(true);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
setError(true);
|
||||
}
|
||||
};
|
||||
|
||||
load();
|
||||
});
|
||||
|
||||
if (error)
|
||||
return (
|
||||
<AuthSingleMessage message="Echec de la finalisation de l'authentification !" />
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<CircularProgress />
|
||||
</>
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user