芝麻web文件管理V1.00
编辑当前文件:/home/freeclou/app.optimyar.com/backend/.cache/admin/src/containers/PrivateRoute/index.js
/** * * PrivateRoute * Higher Order Component that blocks navigation when the user is not logged in * and redirect the user to login page * * Wrap your protected routes to secure your container */ import React, { memo } from 'react'; import { Redirect, Route } from 'react-router-dom'; import PropTypes from 'prop-types'; import { auth } from 'strapi-helper-plugin'; /* eslint-disable react/jsx-curly-newline */ const PrivateRoute = ({ component: Component, path, ...rest }) => (
auth.getToken() !== null ? (
) : (
) } /> ); PrivateRoute.propTypes = { component: PropTypes.oneOfType([PropTypes.node, PropTypes.func]).isRequired, path: PropTypes.string.isRequired, }; export default memo(PrivateRoute);