Last change
on this file was 0f5aa27, checked in by darsov2 <62809499+darsov2@…>, 14 months ago |
ouath, mailing impl
|
-
Property mode
set to
100644
|
File size:
451 bytes
|
Line | |
---|
1 | import React from 'react'
|
---|
2 | import { Navigate } from 'react-router-dom'
|
---|
3 | import {useAuth} from "../Context/AuthContext";
|
---|
4 |
|
---|
5 | function 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 |
|
---|
18 | export default PrivateRoute |
---|
Note:
See
TracBrowser
for help on using the repository browser.