Last change
on this file since 0f5aa27 was 0f5aa27, checked in by darsov2 <62809499+darsov2@…>, 9 months ago |
ouath, mailing impl
|
-
Property mode
set to
100644
|
File size:
451 bytes
|
Rev | Line | |
---|
[e6c2521] | 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()
|
---|
[0f5aa27] | 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" />
|
---|
[e6c2521] | 16 | }
|
---|
| 17 |
|
---|
| 18 | export default PrivateRoute |
---|
Note:
See
TracBrowser
for help on using the repository browser.