-
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.
* fix: accessToken 유무에 따라 내 그룹 목록 요청이가도록 쿼리 옵션 추가 * feat: 권한이 없는 페이지 접근 시 redirect 시키는 고차 컴포넌트 작성 * feat: 접근 권한이 필요한 페이지 withAuthRequired 고차 컴포넌트 적용 * refactor: HOC를 export default 부분에서 사용
- Loading branch information
Showing
8 changed files
with
76 additions
and
27 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
'use client'; | ||
|
||
import withAuthRequired from '@/hocs/withAuthRequired'; | ||
|
||
import CreateBookGroupFunnel from '@/v1/bookGroup/create/CreateBookGroupFunnel'; | ||
|
||
const GroupCreateFunnelPage = () => { | ||
return <CreateBookGroupFunnel />; | ||
}; | ||
|
||
export default GroupCreateFunnelPage; | ||
export default withAuthRequired(GroupCreateFunnelPage); |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
'use client'; | ||
|
||
import { useRouter } from 'next/navigation'; | ||
import { useEffect, useState } from 'react'; | ||
|
||
import { checkAuthentication } from '@/utils/helpers'; | ||
|
||
const withAuthRequired = <P extends object>( | ||
WrappedComponent: React.ComponentType<P> | ||
) => { | ||
const Component = (props: P) => { | ||
const router = useRouter(); | ||
|
||
const [isAuthenticated, setIsAuthenticated] = useState(false); | ||
|
||
useEffect(() => { | ||
const hasAccessToken = checkAuthentication(); | ||
|
||
if (!hasAccessToken) { | ||
router.push('/login'); | ||
} else { | ||
setIsAuthenticated(hasAccessToken); | ||
} | ||
}, [router]); | ||
|
||
if (!isAuthenticated) { | ||
return null; | ||
} else { | ||
return <WrappedComponent {...props} />; | ||
} | ||
}; | ||
|
||
return Component; | ||
}; | ||
|
||
export default withAuthRequired; |
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