-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #893 from KEEPER31337/feature/어드민페이지_URL로_접근가능_#888
Feature/어드민페이지 url로 접근가능 #888
- Loading branch information
Showing
4 changed files
with
135 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import { Role } from '@api/dto'; | ||
import useCheckAuth from '@hooks/useCheckAuth'; | ||
import ConfirmModal from '@components/Modal/ConfirmModal'; | ||
|
||
interface NeedLoginProps { | ||
children: JSX.Element; | ||
roles?: Role[]; | ||
} | ||
|
||
const NeedAuth = ({ children, roles = [] }: NeedLoginProps) => { | ||
const { checkIncludeOneOfAuths } = useCheckAuth(); | ||
const navigate = useNavigate(); | ||
|
||
const onClose = () => { | ||
navigate('/'); | ||
}; | ||
|
||
if (checkIncludeOneOfAuths([...roles, 'ROLE_회장', 'ROLE_부회장'])) { | ||
return children; | ||
} | ||
return ( | ||
<ConfirmModal open onClose={onClose} title="권한이 필요한 서비스입니다"> | ||
<p>접근 권한이 없습니다</p> | ||
</ConfirmModal> | ||
); | ||
}; | ||
|
||
export default NeedAuth; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import useCheckAuth from '@hooks/useCheckAuth'; | ||
import ConfirmModal from '@components/Modal/ConfirmModal'; | ||
|
||
interface NeedLoginProps { | ||
children: JSX.Element; | ||
} | ||
|
||
const NeedLogin = ({ children }: NeedLoginProps) => { | ||
const { checkLogin } = useCheckAuth(); | ||
const navigate = useNavigate(); | ||
|
||
const onClose = () => { | ||
navigate('/login'); | ||
}; | ||
|
||
if (checkLogin()) { | ||
return children; | ||
} | ||
return ( | ||
<ConfirmModal open onClose={onClose} title="로그인이 필요한 서비스입니다"> | ||
<p>로그인 후 이용해주세요</p> | ||
</ConfirmModal> | ||
); | ||
}; | ||
|
||
export default NeedLogin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters