fix: 구글 로그인 코드 파싱 로직 수정#131
Merged
Merged
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
💡 다음 이슈를 해결했어요.
구글 OAuth가 끝나면 구글이 /signup으로 리다이렉트하면서 인가 코드(code)를 쿼리 파라미터로 붙여줌
그 code를 백엔드(/v1/auth/login/google/callback)로 보내야 로그인이 완료되는데, 이전 로직에서 code 값을 잘못 잘라내고 있었음
이게 문제가 됐던 코드인데
이 코드는 "쿼리스트링의 첫 번째 파라미터는 무조건 ?code= 이다" 라고 가정하고 돌아가는 코드임
아마 예전에는 이게 동작했던거로 보임. 근데 어느 순간부터 구글에서 code가 아닌 다른 값을 맨 앞에 붙여서 보내기 시작했고(= 스펙 변경) 그때부터 구글 로그인이 먹통이 된거임
이런식으로 iss라는게 추가가 됨
💡 이슈를 처리하면서 추가된 코드가 있어요.
URLSearchParams를 사용해서 "code"가 몇번째에 위치하는지와 상관없이 해당하는 값을 파싱하도록 수정했고
이걸 사용하면 decodeURIComponent도 사용할 필요가 없어서 제거함
✅ 셀프 체크리스트