-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: implement base code for kakao oauth #4
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,45 @@ | ||
import type { Account, DefaultSession } from 'next-auth' | ||
import NextAuth from 'next-auth/next' | ||
import KakaoProvider from 'next-auth/providers/kakao' | ||
|
||
declare module 'next-auth' { | ||
interface Session { | ||
user: { | ||
id: string | ||
accessToken: string | ||
account: Account | ||
} & DefaultSession['user'] | ||
} | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
const handler = NextAuth({ | ||
providers: [ | ||
KakaoProvider({ | ||
clientId: process.env.AUTH_KAKAO_ID!, | ||
clientSecret: process.env.AUTH_KAKAO_SECRET!, | ||
}), | ||
], | ||
secret: process.env.NEXTAUTH_SECRET!, | ||
callbacks: { | ||
jwt: ({ token, account }) => { | ||
/** | ||
* TODO: Backend API 호출 with account.access_token | ||
*/ | ||
token.accessToken = 'backend api access token' | ||
token.account = account | ||
|
||
return token | ||
}, | ||
|
||
session: ({ session, token }) => { | ||
session.user.id = token.sub || '' | ||
session.user.accessToken = token.accessToken as string | ||
session.user.account = token.account as Account | ||
|
||
return session | ||
}, | ||
}, | ||
}) | ||
|
||
export { handler as GET, handler as POST } | ||
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 client' | ||
|
||
import { signIn } from 'next-auth/react' | ||
import { Button } from '@/components/ui/button' | ||
import Image from 'next/image' | ||
|
||
export default function SignIn() { | ||
return ( | ||
<main className="flex justify-center"> | ||
<div className="mt-16"> | ||
<Button | ||
className="w-full bg-[#FBE44D] text-[#3C1E1E] hover:bg-[#FBE44D]/80" | ||
onClick={() => signIn('kakao')} | ||
> | ||
<Image src="/icons/kakao.svg" alt="" width={20} height={20} className="mr-[12px]" /> | ||
카카오 로그인 | ||
</Button> | ||
</div> | ||
</main> | ||
) | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이제 보니깐 EOL(End of Line) 설정이 안되어있는 것 같아요. 다른 PR들도 동일합니다!
프리티어에 EOL 설정 넣어주시면 감사하겠습니다~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EOL 설정 되어있는 것 확인했습니다!
깃허브에서는 이러한 개행 문자를 시각적으로 표시하지 않는다고 합니다!
실제로 EOL이 적용되어있지 않으면 깃허브에서 다음과 같이 경고를 해줍니다!