Skip to content

fix: 소셜로그인 방식 수정#143

Merged
heeeeyong merged 2 commits intodevelopfrom
chore/minor-updates
Aug 17, 2025
Merged

fix: 소셜로그인 방식 수정#143
heeeeyong merged 2 commits intodevelopfrom
chore/minor-updates

Conversation

@heeeeyong
Copy link
Collaborator

@heeeeyong heeeeyong commented Aug 17, 2025

#️⃣연관된 이슈

#73 [API] auth API 연동

📝작업 내용

  1. 새로운 사용자인 경우
    리다이렉트 : /signup -> 임시토큰을 발급받아서 사용 -> 회원가입 절차 진행 후 엑세스토큰을 받아서 교체후 사용
  2. 기존 사용자인 경우
    리다이렉트 : /feed -> 바로 토큰 사용
  • FE에서 분기 처리 방식
    회원가입 성공시, localStorage의 토큰을 새로운 토큰으로 교체

이미 회원인 경우, 그냥 바로 토큰 사용 3. 토큰이 만료되지 않은 경우 로그인 페이지로 이동시, /feed로 리다이렉트 4. 토큰이 만료된 경우 로그인페이지로 리다이렉트

💬리뷰 요구사항

없음

@vercel
Copy link

vercel bot commented Aug 17, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
thip Ready Ready Preview Comment Aug 17, 2025 8:51am

@coderabbitai
Copy link

coderabbitai bot commented Aug 17, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

인증 흐름을 쿠키 기반에서 localStorage 토큰 기반으로 전환. 교환/쿠키 설정 API 제거, 신규 getToken API 추가. apiClient 인터셉터가 localStorage의 authToken을 사용하고 401 시 루트로 리다이렉트. useSocialLoginToken 훅이 토큰 발급을 기다리도록 변경되어 Feed/Signup/Login 플로우를 동기화.

Changes

Cohort / File(s) Summary
Auth API 제거
src/api/auth/exchangeTempToken.ts, src/api/auth/setCookie.ts
임시 토큰 교환 및 쿠키 설정 API 모듈 삭제. 관련 공개 타입/인터페이스/함수 제거.
Auth API 추가/재구성
src/api/auth/getToken.ts, src/api/auth/index.ts
getToken 추가(POST /auth/token, request: loginTokenKey, response: data.token). auth 인덱스에서 setCookie, exchangeTempToken 제거, getToken 재export.
API 클라이언트 인터셉터
src/api/index.ts
요청 시 localStorage의 authToken을 Authorization 헤더로 설정. 쿠키 파싱 제거. 응답 401 시 '/'로 리다이렉트 활성화.
유저 가입 API 스키마
src/api/users/postSignup.ts
successisSuccess로 필드명 변경. data.accessToken 필드 추가.
소셜 로그인 토큰 훅
src/hooks/useSocialLoginToken.ts
getToken({ loginTokenKey }) 사용해 토큰 발급 후 localStorage authToken 저장. URL에서 loginTokenKey 제거. waitForToken Promise 반환하도록 공개 API 변경.
페이지 - 피드/로그인/회원가입
src/pages/feed/Feed.tsx, src/pages/login/Login.tsx, src/pages/signup/SignupGenre.tsx, src/pages/signup/SignupNickname.tsx
Feed: 토큰 대기 후 로딩, 토큰 없으면 중단. Login: authToken 존재 시 /feed로 리다이렉트. SignupGenre: isSuccess 분기, accessToken을 localStorage 저장. SignupNickname: waitForToken 대기 후 토큰 검증, 없으면 에러 처리.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Browser
  participant useSocialLoginToken
  participant AuthAPI as getToken API
  participant apiClient
  participant Server
  participant LocalStorage

  User->>Browser: 소셜 로그인 리다이렉트 (URL에 loginTokenKey)
  Browser->>useSocialLoginToken: 훅 초기화
  useSocialLoginToken->>AuthAPI: getToken({ loginTokenKey })
  AuthAPI->>apiClient: POST /auth/token
  apiClient->>Server: Authorization 없음(초기), withCredentials
  Server-->>apiClient: { data: { token } }
  apiClient-->>AuthAPI: 응답 전달
  AuthAPI-->>useSocialLoginToken: token 반환
  useSocialLoginToken->>LocalStorage: setItem('authToken', token)
  useSocialLoginToken->>Browser: URL에서 loginTokenKey 제거
Loading
sequenceDiagram
  participant Component as Feed/SignupNickname
  participant useSocialLoginToken
  participant LocalStorage
  participant apiClient
  participant Backend

  Component->>useSocialLoginToken: waitForToken()
  useSocialLoginToken-->>Component: Promise resolved
  Component->>LocalStorage: getItem('authToken')
  LocalStorage-->>Component: token
  Component->>apiClient: API 요청 (Authorization: Bearer token)
  apiClient->>Backend: 요청 전달
  Backend-->>apiClient: 200 또는 401
  alt 401 Unauthorized
    apiClient->>Component: 에러
    apiClient->>Browser: window.location.href = '/'
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

🐞 BugFix

Suggested reviewers

  • ho0010

Poem

귀가 달싹, 토큰이 왔네 — 찰칵 localStorage에 저장!
쿠키는 안녕, 베어러로 인사
피드는 토큰 기다려 살포시 열린다
로그인 길 잃지 말고, 401이면 집으로 hop!
오늘도 깡총, 깡총 — 안전하게 로그인 완료 🥕🐇


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 1f25c00 and a643c5b.

📒 Files selected for processing (11)
  • src/api/auth/exchangeTempToken.ts (0 hunks)
  • src/api/auth/getToken.ts (1 hunks)
  • src/api/auth/index.ts (1 hunks)
  • src/api/auth/setCookie.ts (0 hunks)
  • src/api/index.ts (2 hunks)
  • src/api/users/postSignup.ts (1 hunks)
  • src/hooks/useSocialLoginToken.ts (3 hunks)
  • src/pages/feed/Feed.tsx (5 hunks)
  • src/pages/login/Login.tsx (1 hunks)
  • src/pages/signup/SignupGenre.tsx (1 hunks)
  • src/pages/signup/SignupNickname.tsx (3 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/minor-updates

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@heeeeyong heeeeyong merged commit 4c51cca into develop Aug 17, 2025
2 of 3 checks passed
@heeeeyong heeeeyong self-assigned this Aug 17, 2025
@heeeeyong heeeeyong added 🐞 BugFix Something isn't working 📬 API 서버 API 통신 labels Aug 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📬 API 서버 API 통신 🐞 BugFix Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant