MCPcopy Create free account
hub / github.com/MankaiHuang/screen-visualization / AuthComponent

Function AuthComponent

src/pages/Authorized.jsx:7–28  ·  view source on GitHub ↗
({
  children,
  route = {
    routes: [],
  },
  location = {
    pathname: '',
  },
  user,
})

Source from the content-addressed store, hash-verified

5import { getRouteAuthority } from '@/utils/utils';
6
7const AuthComponent = ({
8 children,
9 route = {
10 routes: [],
11 },
12 location = {
13 pathname: '',
14 },
15 user,
16}) => {
17 const { currentUser } = user;
18 const { routes = [] } = route;
19 const isLogin = currentUser && currentUser.name;
20 return (
21 <Authorized
22 authority={getRouteAuthority(location.pathname, routes) || ''}
23 noMatch={isLogin ? <Redirect to="/exception/403" /> : <Redirect to="/user/login" />}
24 >
25 {children}
26 </Authorized>
27 );
28};
29
30export default connect(({ user }) => ({
31 user,

Callers

nothing calls this directly

Calls 1

getRouteAuthorityFunction · 0.90

Tested by

no test coverage detected