generated from kode-krew/nextjs-template
-
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: 전반적인 인증 구조 개편 및 기타 로직 리팩터링 (#87)
* Fix: verifyGuard page layout 추가 (#81) * Refactor: 인증 인가 서버 route 처리 및 서버 컴포넌트 가딩 처리 1단계 작업 (#82) * WIP: social-login server component 단 처리중 * Fix: social-login server route 처리 및 예외 처리 추가 * Fix: home header 로그인 여부 server component 처리로 전환 (#83) * Fix: login 유지 서버 처리 추가 및 authProvider 로직 추가, 기타 리팩터링 (#85) * Fix: useSearchParams build prerendering error (#84) * Fix: 로그아웃 기능 및 기타 파일명 등 수정 (#86) * Fix: logout 기능 및 기타 변수명 등 수정 * Fix: rebase 후, 파일 명 수정 반영
- Loading branch information
1 parent
cf28f4d
commit e8627d8
Showing
31 changed files
with
537 additions
and
275 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,12 +1,13 @@ | ||
import defaultRequest from '@src/lib/axios/defaultRequest'; | ||
import { UserInformationResponse } from '@src/types/api/Signs'; | ||
import axios from 'axios'; | ||
|
||
interface PostLoginBody { | ||
email: string; | ||
password: string; | ||
} | ||
|
||
export const postLogin = async (body: PostLoginBody) => { | ||
const data = await defaultRequest.post<UserInformationResponse>('/auth/token', { ...body }); | ||
const data = await axios.post<UserInformationResponse>('/api/auth', { ...body }); | ||
return data; | ||
}; |
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,23 +1,24 @@ | ||
import HomeFooterButton from '@src/components/screens/home/components/HomeFooterButton'; | ||
import HomeBody from '@src/components/screens/home/section/HomeBody'; | ||
import HomeFooter from '@src/components/screens/home/section/HomeFooter'; | ||
import dynamic from 'next/dynamic'; | ||
import HomeHeaderButton from '@src/components/screens/home/section/HomeHeaderButton'; | ||
import { checkToken } from '@src/lib/server/auth/checkToken'; | ||
import { AuthService } from '@src/service/AuthService'; | ||
import { cookies } from 'next/headers'; | ||
|
||
const HomeHeaderButton = dynamic( | ||
() => import('@src/components/screens/home/section/HomeHeaderButton'), | ||
{ | ||
ssr: false, | ||
}, | ||
); | ||
const HomePage = async () => { | ||
const accessToken = cookies().get('atk')?.value; | ||
const { isLogin } = await checkToken(accessToken); | ||
|
||
const HomePage = () => ( | ||
<div className="w-screen"> | ||
<header className="m-5 flex h-10 flex-row-reverse"> | ||
<HomeHeaderButton /> | ||
</header> | ||
<HomeBody /> | ||
<HomeFooter /> | ||
<HomeFooterButton /> | ||
</div> | ||
); | ||
return ( | ||
<div className="w-screen"> | ||
<header className="m-5 flex h-10 flex-row-reverse"> | ||
<HomeHeaderButton isLogin={isLogin} /> | ||
</header> | ||
<HomeBody /> | ||
<HomeFooter /> | ||
<HomeFooterButton /> | ||
</div> | ||
); | ||
}; | ||
export default HomePage; |
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,7 @@ | ||
'use server'; | ||
|
||
import { revalidatePath } from 'next/cache'; | ||
|
||
export async function renewAllCache() { | ||
return revalidatePath('/'); | ||
} |
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,21 @@ | ||
'use server'; | ||
|
||
import { cookies } from 'next/headers'; | ||
|
||
export const setAuthCookie = async (token: { atk: string; rtk: string }) => { | ||
await cookies().set('rtk', token.rtk, { | ||
httpOnly: true, | ||
secure: process.env.NODE_ENV === 'production', | ||
maxAge: 60 * 60 * 24 * 14, // 2주 | ||
path: '/', | ||
sameSite: 'strict', | ||
}); | ||
// Refresh Token을 HttpOnly 쿠키로 설정 (기간 2주) | ||
await cookies().set('atk', token.atk, { | ||
httpOnly: true, | ||
secure: process.env.NODE_ENV === 'production', | ||
maxAge: 60 * 30, // 30분 | ||
path: '/', | ||
sameSite: 'strict', | ||
}); | ||
}; |
Oops, something went wrong.