Feat/#107 이메일휴대폰 사전검증 api 연동#113
Hidden character warning
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- loginStudent / refreshToken API 훅 생성 (orval 자동생성) - expo-secure-store 기반 토큰 저장소 구현 (refreshToken → SecureStore, accessToken → 메모리) - axios interceptor 401 자동 갱신 + 무한루프 방지 - 앱 시작 시 역할 기반 자동 로그인 (STUDENT / ADMIN / PARTNER) - LMS 학생 로그인 버튼 활성화 (SSU WebView 연동) - useSignupFlowController 리팩토링 (action hook 분리) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Thanks for the contribution! Please review the labels and make any necessary changes. |
There was a problem hiding this comment.
Code Review
This pull request implements the student authentication and signup flow, integrating SSU LMS verification via WebView and managing session state with expo-secure-store and Zustand. Feedback highlights a critical omission where authentication tokens are not saved after signup, potentially causing immediate session loss. Other recommendations include removing sensitive data logging in API interceptors, externalizing debug flags to environment variables, and replacing hardcoded user roles with dynamic values from the auth store to improve security and maintainability.
| if (!response.isSuccess) { | ||
| Alert.alert( | ||
| "회원가입 실패", | ||
| response.message ?? "회원가입에 실패했습니다.", | ||
| [{ text: "확인", onPress: onFailure }], | ||
| ); | ||
| return; | ||
| } | ||
|
|
||
| onSuccess(); |
There was a problem hiding this comment.
회원가입 API 호출 성공 후 서버로부터 반환된 토큰과 사용자 역할을 저장하는 로직이 누락되었습니다. useStudentLoginAction과 동일하게 completeLogin을 호출하여 인증 상태를 유지하고 토큰을 저장해야 합니다. 그렇지 않으면 회원가입 완료 후 홈 화면으로 이동했을 때 인증되지 않은 사용자로 처리되어 다시 로그인 화면으로 이동하게 됩니다.
또한 assertSuccess 유틸리티를 사용하여 응답 검증 로직을 공통화하는 것을 권장합니다. (참고: assertSuccess와 completeLogin 임포트가 필요합니다.)
if (!response.isSuccess) {
Alert.alert(
"회원가입 실패",
response.message ?? "회원가입에 실패했습니다.",
[{ text: "확인", onPress: onFailure }],
);
return;
}
const { tokens, role } = response.result;
await completeLogin(tokens ?? {}, role);
onSuccess();| console.log( | ||
| "[API REQ]", | ||
| config.method?.toUpperCase(), | ||
| config.url, | ||
| JSON.stringify(config.data), | ||
| ); |
There was a problem hiding this comment.
| import { useStudentVerificationAction } from "./useStudentVerificationAction"; | ||
|
|
||
| export function useSignupFlowController() { | ||
| const FORCE_PHONE_VERIFICATION_BYPASS = false; |
| }, | ||
| onBottomButtonPress: async () => { | ||
| if (step === "complete") { | ||
| router.replace(getHomeRouteByRole("STUDENT") as never); |
…전검증-api-연동 # Conflicts: # app.json
개요
학생 회원가입 및 로그인 API를 연동하고, 토큰 관리 아키텍처를 구축했습니다.
변경 사항
1. API 코드 생성 (orval)
OpenAPI 스펙 기반으로 4개 API의 타입/함수를 자동 생성했습니다.
_generated/auth/ssuAuth.ts_generated/auth/signupStudent.ts_generated/auth/loginStudent.ts_generated/auth/refreshToken.ts2. 토큰 관리 아키텍처
저장 전략
accessTokenrefreshTokenexpo-secure-storeuserRoleexpo-secure-store주요 파일
src/shared/api/token-storage.ts— SecureStore CRUD 유틸src/shared/lib/auth/authStore.ts— accessToken/role Zustand 스토어src/shared/api/auth.ts—saveTokens,clearTokens,initAuth,getHomeRouteByRole401 자동 갱신 (
interceptors.ts)accessToken을 읽어 Authorization 헤더 주입refreshToken으로 자동 재발급 후 원본 요청 재시도_retry플래그로 무한 루프 방지3. 학생 플로우 API 연동
React Query 훅
api/useSSUAuthMutation.ts— U-SAINT WebView 인증 결과 처리api/useSignupMutation.ts— 학생 회원가입 요청api/useLoginStudentMutation.ts— 학생 로그인 (LMS)api/useRefreshTokenMutation.ts— 토큰 재발급Action 훅 (model 레이어)
model/useStudentVerificationAction.ts— U-SAINT WebView 노출/응답 처리, 인증 완료 시 학번·전공·이름 자동 입력model/useStudentSignupAction.ts— 회원가입 요청, 실패 시 로그인 화면으로 이동model/useStudentLoginAction.ts— LMS WebView 노출/응답 처리, 로그인 성공 시 토큰 저장 및 학생 홈으로 이동4. 자동 로그인
앱 시작 시
initAuth()를 호출해 저장된refreshToken으로 액세스 토큰을 재발급합니다.역할(
STUDENT/ADMIN/PARTNER)에 따라 각각의 홈 화면으로 자동 이동합니다.5. 리팩토링
useSignupFlowController.ts에 집중돼 있던 로직을 3개 action 훅으로 분리했습니다 (362줄 → 230줄).동작 변화 없음.
스크린샷 / 플로우
체크리스트