Browse Source

김항소 계정으로 로그인 시 비행승인신청관리 화면 접근

master
이준희 3 months ago
parent
commit
2d9da88578
  1. 4
      src/components/account/login/AccountLogin.js
  2. 14
      src/router/hoc/authenticationCheck.tsx

4
src/components/account/login/AccountLogin.js

@ -68,8 +68,12 @@ export const AccountLogin = ({ history }) => {
const { meta } = await dispatch(setLogin(loginForm));
if (meta.requestStatus === 'fulfilled') {
if (loginForm?.userId === 'dos-gmp') {
history.push('/flight/Approvals/new');
} else {
history.push('/control');
}
}
};
return (

14
src/router/hoc/authenticationCheck.tsx

@ -1,5 +1,5 @@
import { ReactNode, useEffect, useLayoutEffect, useState } from 'react';
import { RouteComponentProps } from 'react-router-dom';
import { RouteComponentProps, useHistory } from 'react-router-dom';
import { useSelector, useDispatch } from '@src/redux/store';
import { checkToken } from '@src/redux/features/account/auth/authThunk';
import { ICheckAuthencationRs } from '@src/redux/features/account/auth/authState';
@ -23,6 +23,7 @@ interface IProps extends RouteComponentProps {
export default function (SpecificComponent: ReactNode, option: IOption) {
function AuthenticationCheck(props: RouteComponentProps) {
const dispatch = useDispatch();
const history = useHistory();
const { user } = useSelector(state => state.authState);
const [isRender, setIsRender] = useState<boolean>(false);
@ -60,6 +61,17 @@ export default function (SpecificComponent: ReactNode, option: IOption) {
};
}, []);
useLayoutEffect(() => {
if (user?.cptAuthCode === 'DF0002') {
const pathname = history.location.pathname;
if (pathname != '/flight/Approvals/new') {
props.history.replace('/flight/Approvals/new');
return;
}
}
}, [user]);
return <>{isRender ? <Component {...props} user={user} /> : null}</>;
}
return AuthenticationCheck;

Loading…
Cancel
Save