Skip to content
Merged

Dev #107

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 26 additions & 19 deletions client/src/app/common/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,33 @@ function Login() {

useEffect(() => {
const code = searchParams.get("code")
console.log("code", code)
console.log("isLogin", isLogin)
if (code) {
//카카오에서 리다이렉트된 경우
getKakaoTokenFromAuthCode(code).then((kakaoToken) => {
login(kakaoToken)
.then(() => {
const returnUrl = searchParams.get("state")
push(returnUrl || "/")
})
.catch((e) => {
const returnUrl = searchParams.get("state")
if (returnUrl === "/retreat/register") {
push(`/retreat/search`)
}
})
})
} else if (isLogin) {
const returnUrl = searchParams.get("returnUrl")
if (isLogin) {
const returnUrl =
searchParams.get("returnUrl") || searchParams.get("state")
push(returnUrl || "/")
} else if (code) {
//카카오에서 리다이렉트된 경우
getKakaoTokenFromAuthCode(code)
.then((kakaoToken) => {
console.log("kakaoToken", kakaoToken)
login(kakaoToken)
.then(() => {
const returnUrl = searchParams.get("state")
push(returnUrl || "/")
})
.catch((e) => {
const returnUrl = searchParams.get("state")
if (returnUrl === "/retreat/register") {
push(`/retreat/search`)
}
})
})
.catch((e) => {
const returnUrl = searchParams.get("state")
if (returnUrl === "/retreat/register") {
push(`/retreat/search`)
}
})
}
}, [searchParams.get("code"), isLogin])

Expand Down
Loading