PrivateRoutes.js 438 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 { isLogined } from './Auth';
Spark's avatar
Spark committed
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

function PrivateRoute({ path, children }) {
    if (isLogined()) {
        return (
            <Route path={path}>
                {children}
            </Route>
        )
    } else {
        alert('권한이 없습니다')
        return (
            <Redirect to='/' />
        )
    }
}
export default PrivateRoute