diff --git a/pac-man-board-game/ClientApp/src/App.tsx b/pac-man-board-game/ClientApp/src/App.tsx index 9b53acd..6086812 100644 --- a/pac-man-board-game/ClientApp/src/App.tsx +++ b/pac-man-board-game/ClientApp/src/App.tsx @@ -1,5 +1,5 @@ -import React, {FC, useEffect} from "react"; -import {Route, Routes, useNavigate} from "react-router-dom"; +import React, {FC} from "react"; +import {Navigate, Route, Routes} from "react-router-dom"; import Layout from "./components/layout"; import AppRoutes from "./AppRoutes"; import "./index.css"; @@ -23,20 +23,14 @@ export const App: FC = () => ( * @param secured Whether or not the page is secured. * @constructor The Secured component. */ -const Secured: FC<{ secured: boolean } & ChildProps> = ({children, secured}) => { +const Secured: FC<{ + secured: boolean +} & ChildProps> = ({children, secured}) => { const player = useAtomValue(thisPlayerAtom); - const navigate = useNavigate(); - const redirect = secured && player === undefined - useEffect(() => { - if (redirect) { - navigate("/login"); - } - }); - - if (!redirect) { - return ( - <>{children} - ) + if (secured && player === undefined) { + return } + + return <>{children} } diff --git a/pac-man-board-game/ClientApp/src/AppRoutes.tsx b/pac-man-board-game/ClientApp/src/AppRoutes.tsx index 85aded3..8fa3cc4 100644 --- a/pac-man-board-game/ClientApp/src/AppRoutes.tsx +++ b/pac-man-board-game/ClientApp/src/AppRoutes.tsx @@ -27,6 +27,10 @@ const AppRoutes = [ { path: "/login", element: + }, + { + path: "*", + element:

Page not found

} ]; diff --git a/pac-man-board-game/Controllers/GenericController.cs b/pac-man-board-game/Controllers/GenericController.cs index 8e06533..8fcee00 100644 --- a/pac-man-board-game/Controllers/GenericController.cs +++ b/pac-man-board-game/Controllers/GenericController.cs @@ -52,7 +52,8 @@ public abstract class GenericController : ControllerBase } while (true); var disconnectSegment = Disconnect(); - if (disconnectSegment != null) SendDisconnectMessage((ArraySegment)disconnectSegment); + if (disconnectSegment != null) + SendDisconnectMessage((ArraySegment)disconnectSegment); await _webSocketService.Close(WebSocket, result.CloseStatus.Value, result.CloseStatusDescription); }