Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TNT-221] 로그인/회원가입/로그아웃/회원탈퇴 간 인증 정보 처리 로직 작성 #64

Merged
merged 8 commits into from
Feb 10, 2025

Conversation

FpRaArNkK
Copy link
Contributor

@FpRaArNkK FpRaArNkK commented Feb 9, 2025

📌 What is the PR?

  • 앱 흐름에서 인증 정보가 처리되는 부분을 API 로직, 키체인과 연결하여 작성했습니다.

🪄 Changes

  • 키체인에 SessionId 추가 로직 작성
  • 앱 진입 시 세션 체크 로직 작성
  • 로그인, 회원 가입 시 세션 저장 로직 작성
  • 로그아웃, 회원 탈퇴 시 세션 삭제 로직 작성
  • 세션 정보에 따른 앱 코디네이트 관리 로직 작성

🌐 Common Changes

  • KeyChainManager가 static에서 기본 함수로 변경, DIContainer에 등록하여 사용합니다
  • API 콜 중 Response가 비어서 오는 응답의 경우 EmptyResponse를 사용하여 받습니다

🔥 PR Point

  1. 앱 진입 시, AppFlowCoordinatorFeature에서 checkSessionInfo를 통해 KeyChain에 등록되어있는 세션 정보를 확인합니다.
    존재하는 경우 API를 통해 유효한지 검증하며, 유효하지 않거나 존재하지 않는 경우 온보딩 화면으로 이동합니다.
    유효한 경우, 각 유저 타입에 맞는 화면으로 라우팅됩니다.
case .api(let action):
                switch action {
                case .checkSession:
                    return .run { send in
                        let result = try? await userUseCaseRepo.getSessionCheck()
                        switch result?.memberType {
                        case .trainer:
                            await send(.updateUserInfo(.trainer))
                        case .trainee:
                            await send(.updateUserInfo(.trainee))
                        default:
                            try keyChainManager.delete(.sessionId)
                            await send(.updateUserInfo(nil))
                        }
                    }
                }
            
            case .checkSessionInfo:
                let session: String? = try? keyChainManager.read(for: .sessionId)
                return session != nil
                ? .send(.api(.checkSession))
                : .send(.updateUserInfo(nil))
                
            case .updateUserInfo(let userType):
                switch userType {
                case .trainee:
                    return self.setFlow(.traineeMainFlow, state: &state)
                case .trainer:
                    return self.setFlow(.trainerMainFlow, state: &state)
                default:
                    return self.setFlow(.onboardingFlow, state: &state)
                }
  1. 마이페이지에서 로그아웃/회원탈퇴 시 API 호출 후 KeyChain 삭제 - 온보딩 화면으로 라우팅 흐름으로 진행됩니다.
    회원 탈퇴 시 API response body가 비어서 오기 때문에 EmptyResponse를 typealias로 바꿔 넣어주었고, 키체인 삭제 후 화면 전환은 코디네이터를 통해 진행했습니다.

🙆🏻 To Reviewers

  • 추후 리팩토링 시에 DTO를 모두 Data단에 옮기게 될 텐데, 이때 EmptyResponse도 꼭 같이 옮겨야할 것 같습니다.
  • 나머지는 [TNT-213] 트레이너 회원목록 페이지 작성 #62 머지 후에 작업이 가능하여 - TrainerUseRepoCase가 필요 - 여기까지 작업후 PR 올립니다!

💭 Related Issues

@FpRaArNkK FpRaArNkK added the ✨Feat 새로운 기능 구현 (새로운 로직 추가, UI 구현 등) label Feb 9, 2025
@FpRaArNkK FpRaArNkK requested a review from syss220211 February 9, 2025 02:36
@FpRaArNkK FpRaArNkK self-assigned this Feb 9, 2025
@FpRaArNkK FpRaArNkK changed the base branch from TNT-221-apiConnectionBase to develop February 10, 2025 15:11
@FpRaArNkK FpRaArNkK merged commit 801341a into develop Feb 10, 2025
@FpRaArNkK FpRaArNkK deleted the TNT-221-apiConnectionBase-userApi branch February 12, 2025 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨Feat 새로운 기능 구현 (새로운 로직 추가, UI 구현 등)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants