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

Network [#75] 회원 가입 & 토큰 리프레시 API 구현 #83

Merged
merged 13 commits into from
Jan 14, 2024

Conversation

kim-seonwoo
Copy link
Member

👾 작업 내용

  • BaseResponse를 이용한 방법으로 전반적으로 수정하였습니다.
  • 회원 가입 API를 구현 하였습니다.
  • 토큰 리프레시 API를 구현 하였습니다.
case .success(let response):
                if (200..<410).contains(response.statusCode) {
                    if let decodeData = try? JSONDecoder().decode(instance, from: response.data) {
                        completion(decodeData)
                    } else{
                        print("🚨 decoding Error 발생")
                    }
                } else if response.statusCode == 401 {
                    let provider = Providers.AuthProvider
                    
                    provider.request(target: .tokenRefresh, instance: BaseResponse<RefreshTokebResponseDTO>.self, viewController: LoginViewController()) { data in
                        if let data = data.data {
                            UserManager.shared.updateToken(data.token.accessToken, data.token.accessToken)
                        }
                        print(data.status, "🚨")}
                } else {
                    print("🚨 Client Error")
                }
  • 다음과 같이 에러 처리를 하여 401 반환시 리프레시를 하게 하였습니다.
  • UserDefault 값 추가 로직을 구현하였습니다.

🚀 PR Point

  • DTO를 잘 보고 설정해야 합니다! -> 디코딩 에러 주의

📸 스크린샷

구현 내용 스크린샷
화면종류 image

✅ Issue

Resolved #75

@kim-seonwoo kim-seonwoo added 😎선우 선우의 issue 📡 network api 작업 labels Jan 14, 2024
@kim-seonwoo kim-seonwoo added this to the 🚀1차 스프린트🚀 milestone Jan 14, 2024
@kim-seonwoo kim-seonwoo self-assigned this Jan 14, 2024
@kim-seonwoo kim-seonwoo linked an issue Jan 14, 2024 that may be closed by this pull request
Copy link
Member

@Zoe0929 Zoe0929 left a comment

Choose a reason for hiding this comment

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

P4. 고생television

}
}


Copy link
Member

Choose a reason for hiding this comment

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

P3. 코드 컨벤션 지켜주세요. 여기 빈줄 삭제해주세용.

Comment on lines +105 to +120
self.navigationController?.pushViewController(nextViewController, animated: false)
let request = SignUpRequestDTO(socialPlatform: "APPLE", name: UserManager.shared.getUserName, onboarding: onboarding, challenge: challenge)
print(request.onboarding.averageUseTime)
let provider = Providers.AuthProvider
provider.request(target: .signUp(data: request), instance: BaseResponse<SignUpResponseDTO>.self, viewController: self) { data in
if data.status == 403 {
let nextViewController = TimeSurveyViewController()
self.navigationController?.pushViewController(nextViewController, animated: false)
} else if data.status == 200 {
self.setRootViewController(TabBarController())
guard let data = data.data else { return }
UserManager.shared.updateToken(data.token.accessToken, data.token.refreshToken)
UserManager.shared.updateUserId(data.userId)
}
guard let data = data.data else { return }
}
Copy link
Member

Choose a reason for hiding this comment

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

P4. 추후 삭제 부탁드립니다.

Copy link
Contributor

@boyeon0119 boyeon0119 left a comment

Choose a reason for hiding this comment

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

LGTM~

@kim-seonwoo kim-seonwoo merged commit c6691e9 into develop Jan 14, 2024
@Zoe0929 Zoe0929 deleted the network/#75-SignUp branch January 19, 2024 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📡 network api 작업 😎선우 선우의 issue
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[Network] 회원가입 API 구현
3 participants