OnlyUser.js 521 Bytes
Newer Older
Spark's avatar
Spark committed
1
2
import React from 'react';
import { Redirect, Route } from 'react-router-dom';
Spark's avatar
Spark committed
3
import PageNotFound from '../components/PageNotFound';
Spark's avatar
Spark committed
4
import { isLogined } from './Auth';
Spark's avatar
Spark committed
5

Spark's avatar
Spark committed
6
function OnlyUser({ path, children }) {
Spark's avatar
Spark committed
7
8
9
10
11
12
13
14
    if (isLogined()) {
        return (
            <Route path={path}>
                {children}
            </Route>
        )
    } else {
        return (
Spark's avatar
Spark committed
15
16
17
18
            <>
                <PageNotFound />
                {/* <Redirect to='/' /> */}
            </>
Spark's avatar
Spark committed
19
20
21
        )
    }
}
Spark's avatar
Spark committed
22
export default OnlyUser