feat(auth): 실제 로그인·인증 연동 (fowoco/server /api/v1/auth/*) - #103
Merged
Conversation
fowoco/server에 이미 구현된 인증 API로 데모 계정 문자열 비교를 대체했다. - authStore: login()이 POST /auth/login을 실제로 호출, 성공 시 access_token은 메모리(#100의 api/client)에, Refresh Token은 서버가 설정하는 HttpOnly 쿠키를 그대로 사용 - restoreSession(): 새로고침 시 POST /auth/refresh로 세션을 조용히 복원하고 GET /auth/me로 role을 받아온다. GET /auth/me가 company_name·표시용 이름을 안 내려주는 서버 쪽 gap이 있어, 로그인 시점에 localStorage(민감정보 아님)에 저장해둔 값으로 보완 — 주석에 이유와 "서버가 필드를 추가하면 제거" 방향을 남겨둠 - logout(): POST /auth/logout 연동, 실패해도 클라이언트 상태는 정리 (서버가 폐기를 보장 못 해도 사용자를 로그인 화면에 묶어두지 않음) - client.ts의 401 → refresh 실패 콜백(authExpiredHandler)을 로그아웃 처리에 연결 - RequireAuth: 앱을 처음 열었을 때(status idle)만 restoreSession을 시도, 로그인 직후에는 재호출하지 않음 - LoginPage: 로그인을 비동기로 처리, 서버가 내려주는 오류 메시지를 그대로 표시 (예: "이메일 또는 비밀번호가 올바르지 않습니다.") ## 확인 필요 (이슈에 기록) 데모 계정(mini@naver.com / 1234)이 서버 DB에 실제로 seed돼 있는지 백엔드팀 확인 필요. Closes #101
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.
개요
fowoco/server에 이미 구현된 인증 API(PR #33, #35)로 데모 계정 문자열 비교 로그인을 대체했다. #100의 공통 API 클라이언트 레이어를 사용한다.변경 사항
authStore.tslogin()이POST /auth/login을 실제로 호출. Access Token은 메모리에, Refresh Token은 서버가 설정하는 HttpOnly 쿠키를 그대로 사용restoreSession()신규: 새로고침 시POST /auth/refresh→GET /auth/me로 세션을 조용히 복원.GET /auth/me가company_name/표시용 이름을 안 내려주는 서버 쪽 gap이 있어, 로그인 시점에 localStorage(민감정보 아님)에 저장해둔 값으로 보완 — 서버가 필드를 추가하면 이 fallback은 제거하면 됨 (주석에 명시)logout()이POST /auth/logout연동. 실패해도 클라이언트 상태는 정리authExpiredHandler(refresh 재시도까지 실패 시 호출)를 로그아웃 처리에 연결RequireAuth.tsx: 앱을 처음 열었을 때(status === 'idle')만restoreSession()시도, 로그인 직후 재호출 안 함LoginPage.tsx: 로그인을 비동기 처리, 서버가 내려주는 오류 메시지를 그대로 표시authStore.test.ts신규(로그인 성공/실패, 401 재시도 안 함, 로그아웃, 세션 복원 성공/실패),RequireAuth/LoginPage테스트를 실제 fetch mock 기반으로 갱신완료 조건
authStore.login을POST /api/v1/auth/login실제 호출로 교체GET /api/v1/auth/me로 세션 복원POST /api/v1/auth/logout연동role값을 화면 표시에 반영확인 필요 (블로킹 아님, 후속 확인)
mini@naver.com/1234)이 서버 DB에 실제로 seed돼 있는지 백엔드팀 확인 필요GET /api/v1/auth/me에company_name/표시용 이름 필드 추가 검토 (현재는 로그인 시점 localStorage 캐시로 우회)검증
npm run lintnpm run test(전체 152개 통과)npm run buildCloses #101