source: frontend/src/Components/Misc/PrivateRoute.js@ 0f5aa27

Last change on this file since 0f5aa27 was 0f5aa27, checked in by darsov2 <62809499+darsov2@…>, 6 months ago

ouath, mailing impl

  • Property mode set to 100644
File size: 451 bytes
Line 
1import React from 'react'
2import { Navigate } from 'react-router-dom'
3import {useAuth} from "../Context/AuthContext";
4
5function PrivateRoute({ children }) {
6 const { userIsAuthenticated } = useAuth()
7 if(userIsAuthenticated())
8 {
9 return children;
10 }
11 else
12 {
13 window.location.href = "http://localhost:8080/login";
14 }
15 return userIsAuthenticated() ? children : <Navigate to="http://localhost:8080/login" />
16}
17
18export default PrivateRoute
Note: See TracBrowser for help on using the repository browser.