Skip to content

[5주차/엠버] 워크북 제출합니다.#52

Open
haewonwon wants to merge 6 commits intoUMC-Inha:엠버/mainfrom
haewonwon:week5
Open

[5주차/엠버] 워크북 제출합니다.#52
haewonwon wants to merge 6 commits intoUMC-Inha:엠버/mainfrom
haewonwon:week5

Conversation

@haewonwon
Copy link
Copy Markdown

@haewonwon haewonwon commented Apr 29, 2026

✅ 워크북 체크리스트

  • 모든 핵심 키워드 정리를 마쳤나요?
  • 핵심 키워드에 대해 완벽히 이해하셨나요?
  • 이론 학습 이후 직접 실습을 해보는 시간을 가졌나요?
  • 미션을 수행하셨나요?
  • 미션을 기록하셨나요?

✅ 컨벤션 체크리스트

  • 디렉토리 구조 컨벤션을 잘 지켰나요?
  • pr 제목을 컨벤션에 맞게 작성하였나요?
  • pr에 해당되는 이슈를 연결하였나요?(중요)
  • 적절한 라벨을 설정하였나요?
  • 파트장에게 code review를 요청하기 위해 reviewer를 등록하였나요?
  • 닉네임/main 브랜치의 최신 상태를 반영하고 있는지 확인했나요?(매우 중요!)

📌 주안점

스터디 전까지 완료하겠습니다...!

@haewonwon haewonwon self-assigned this Apr 29, 2026
@haewonwon haewonwon requested a review from qkrdmsthff as a code owner April 29, 2026 13:44
@haewonwon haewonwon changed the title [5주차/엘리] 워크북 제출합니다. [5주차/엠버] 워크북 제출합니다. Apr 29, 2026
const ACCESS_TOKEN_KEYS = ['accessToken', 'access_token', 'token'];
const REFRESH_TOKEN_KEYS = ['refreshToken', 'refresh_token'];

function getValueByCandidates(params: URLSearchParams, candidates: string[]) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 함수는 어떤 기능을 가지고 있는지 궁금합니다!

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

input 컴포넌트를 따로 분리해서 사용한 점이 깔끔하고 좋아 보이네요!

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/auth/signin ↔ /auth/signup 간 이동 시 errorMessage / successMessage state가 초기화되지 않아 이전 폼의 메시지가 남을 수 있습니다.

이유:
두 경로 모두 AuthPage 컴포넌트를 렌더링하기 때문에 경로가 바뀌어도 React는 컴포넌트를 새로 마운트하지 않고 기존 인스턴스를 재사용합니다. 따라서 useState로 관리하는 메시지 상태가 경로 전환 시 초기화되지 않습니다.

  1. /auth/signup 에서 이미 가입된 이메일로 회원가입 시도
    → errorMessage = "이미 사용 중인 이메일입니다."

  2. 로그인 링크 클릭 → /auth/signin 이동
    → 로그인 폼 위에 "이미 사용 중인 이메일입니다." 가 그대로 표시됨

수정 예시

  useEffect(() => {
    setErrorMessage('');
    setSuccessMessage('');
  }, [location.pathname]);

경로가 바뀌는 시점에 메시지를 초기화해 이전 폼의 메시지가 남아있지 않도록 합니다!

관련 사이트 첨부합니다.
https://react.dev/learn/preserving-and-resetting-state
(여기에서는 권장 사항으로 key를 사용하라고 되어있네요!!)

import { setAuthTokens } from '../../utils/authToken';

const ACCESS_TOKEN_KEYS = ['accessToken', 'access_token', 'token'];
const REFRESH_TOKEN_KEYS = ['refreshToken', 'refresh_token'];
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

토큰 키 이름을 상수 배열로 처리해서 서버가 키 이름을 바꿔도 어느정도 유연하게 대응할 수 있다는 점이 매우 좋은 것 같습니다 !! 저도 적용해봐야겠어요 👍🏻

Copy link
Copy Markdown
Collaborator

@qkrdmsthff qkrdmsthff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 엠버 ~~ 수고하셨고 코드리뷰 반영해 주세요!

Comment on lines +33 to +43
export function signup(payload: SignupRequest) {
return postJson<SignupResponseData>('/auth/signup', payload);
}

export function signin(payload: SigninRequest) {
return postJson<SigninResponseData>('/auth/signin', payload);
}

export function signout() {
return postJson<null>('/auth/signout', {});
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

현재는 postJson 를 사용하시고 계신데, 이를 사용하신 이유가 있을까요?

실제 서비스에서는 GET, PUT, DELETE 등의 다양한 메서드를 필요로 합니다! apiClient 인스턴스를 직접 사용하시거나, 더 범용적인 request 유틸리티로 확장해 보는 것을 추천합니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chapter05_리프레시 토큰 기반의 안전한 접근 제어 전략과 소셜 로그인

5 participants