({
children,
route = {
routes: [],
},
location = {
pathname: '',
},
user,
})
| 5 | import { getRouteAuthority } from '@/utils/utils'; |
| 6 | |
| 7 | const 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 | |
| 30 | export default connect(({ user }) => ({ |
| 31 | user, |
nothing calls this directly
no test coverage detected