You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
이 PR은 시연(데모) 계정 로그인 기능을 추가하는 작업으로, 로그인 기능의 비동기 처리 및 UI 요소가 변경되었습니다.
주요 리스크는 비동기 처리 중 에러 핸들링이 부족할 수 있으며, 상태 관리와 관련된 부분에서 불필요한 리렌더링이 발생할 가능성이 있습니다.
⚠️ 세부 코드 리뷰
[src/features/auth/pages/LoginPage.tsx:14-35]
문제 설명: onSubmit 함수 내에서 setSubmitting(true)를 호출한 후, fetchLogin을 호출하기 전에 setSubmitting(false)를 호출하지 않음.
원인: 로그인 요청이 실패할 경우, submitting 상태가 true로 남아있어 사용자가 다시 로그인 시도를 할 수 없음.
개선 방안: 로그인 요청 후 성공 또는 실패에 따라 setSubmitting(false)를 호출하여 상태를 초기화해야 함.
코드 예시:
constonSubmit=async(e: SyntheticEvent<HTMLFormElement,SubmitEvent>)=>{e.preventDefault();setSubmitting(true);constform=newFormData(e.targetasHTMLFormElement);constemail=String(form.get('email')||'');constpassword=String(form.get('password')||'');try{awaitfetchLogin(email,password);}catch(error){// 에러 처리 로직 추가 (예: alert)}finally{setSubmitting(false);// 항상 상태를 초기화}};
[src/lib/utils/authRequest.ts:96]
문제 설명: 에러 발생 시 setToken('', '');을 호출하여 토큰을 초기화함.
원인: 이 로직은 API 요청이 실패할 때마다 토큰을 초기화하게 되어, 사용자가 로그인 상태를 유지하지 못하게 할 수 있음.
개선 방안: 에러 발생 시 토큰 초기화 로직을 제거하거나, 특정 에러 상황에서만 초기화하도록 조건을 추가해야 함.
코드 예시:
if(err.name==='UnauthorizedError'){setToken('','');// 특정 에러 상황에서만 초기화}
[src/features/auth/pages/LoginPage.tsx:30-35]
문제 설명: fetchLogin 함수가 client 변수를 사용하고 있지만, 해당 변수가 정의되지 않음.
원인: useAuthedClient 훅을 통해 클라이언트를 가져와야 하는데, 이를 사용하지 않음.
개선 방안: useAuthedClient를 사용하여 클라이언트를 가져오고, fetchLogin에 전달해야 함.
코드 예시:
constclient=useAuthedClient();
🧪 테스트 제안
로그인 버튼 클릭 시 정상적으로 로그인 요청이 이루어지는지 확인하는 테스트 케이스를 작성합니다.
로그인 실패 시 사용자에게 적절한 에러 메시지가 표시되는지 확인하는 테스트 케이스를 추가합니다.
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
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.
#️⃣ 연관된 이슈
📝 작업 내용
🖼️ 스크린샷 (선택)
💬 리뷰 요구사항 (선택)