AdminRoute.js 406 Bytes
Newer Older
kusang96's avatar
kusang96 committed
1
2
3
4
5
6
7
8
9
10
11
12
import React from 'react';
import { Redirect, Route } from 'react-router-dom';
import { isAdmin } from '../utils/auth';

function PrivateRoute({path, children}) {
  if (isAdmin()) {
    return (
      <Route path={path}>
        {children}
      </Route>
    )
  } else {
kusang96's avatar
DSAD    
kusang96 committed
13
    alert('권한이 없습니다. 죄송합니다.');
kusang96's avatar
kusang96 committed
14
15
16
17
18
19
20
    return (
      <Redirect to='/' />
    )
  }
}

export default PrivateRoute