diff --git a/frontend/src/pages/HomePage.jsx b/frontend/src/pages/HomePage.jsx index 527d63a..f016608 100644 --- a/frontend/src/pages/HomePage.jsx +++ b/frontend/src/pages/HomePage.jsx @@ -1,7 +1,16 @@ +import { useEffect } from "react"; import { Container } from "react-bootstrap"; import MyNavbar from "../components/MyNavbar"; const HomePage = () => { + {/*{current_user} = use context*/} + const current_user = null; + + useEffect(()=>{ + if (!current_user) { + window.location.replace("/login"); + } + }, []); return (
diff --git a/frontend/src/pages/LoginPage.jsx b/frontend/src/pages/LoginPage.jsx index 14672bc..220eb56 100644 --- a/frontend/src/pages/LoginPage.jsx +++ b/frontend/src/pages/LoginPage.jsx @@ -1,5 +1,5 @@ import React, { useState } from "react"; -import { Button, Col, Container, Form, Row, Alert} from "react-bootstrap"; +import { Button, Col, Container, Form, Row, Alert } from "react-bootstrap"; import MyNavbar from "../components/MyNavbar"; import { makeRequest } from "../utils.ts"; @@ -9,7 +9,7 @@ const LoginPage = () => { const [error, setError] = useState(null); const sendLoginRequest = async (e) => { - e.preventDefault(); + e?.preventDefault(); await makeRequest({ url: "http://localhost:5000/login", method: "POST", @@ -29,8 +29,12 @@ const LoginPage = () => { return ( - { error && ( - ERROR! {error.message} + {error && ( + + + {error.message} + + )}