-
Notifications
You must be signed in to change notification settings - Fork 15
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
[Feat] #197 - 토큰 재발급 정상 작동하도록 수정 / 플그 미등록 비활동 유저 자동로그인 처리 / 스플래시 이미지 변경 #200
Changes from all commits
70863cc
b52cfb7
4e50e61
f092fd8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,9 +25,19 @@ public class MainRepository { | |
} | ||
|
||
extension MainRepository: MainRepositoryInterface { | ||
public func getUserMainInfo() -> AnyPublisher<Domain.UserMainInfoModel?, Error> { | ||
public func getUserMainInfo() -> AnyPublisher<Domain.UserMainInfoModel?, Never> { | ||
userService.getUserMainInfo() | ||
.map { $0.toDomain() } | ||
.catch({ error in | ||
var model: UserMainInfoModel? | ||
if let error = error as? APIError, | ||
case .tokenReissuanceFailed = error { | ||
model = UserMainInfoModel(withError: false) | ||
} else { | ||
model = UserMainInfoModel(withError: true) | ||
} | ||
return Just(model) | ||
}) | ||
Comment on lines
+31
to
+40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍🏻 |
||
.eraseToAnyPublisher() | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,13 +32,15 @@ extension SignInRepository: SignInRepositoryInterface { | |
authService.signIn(token: token) | ||
.catch ({ error in | ||
guard | ||
let error = error as? SOPTAPPError, | ||
let error = error as? APIError, | ||
case .network(let statusCode) = error, | ||
statusCode == 400 | ||
else { | ||
return self.userService.reissuance() | ||
} | ||
|
||
// NOTE: (@준호) 플그 미등록 + 비활동 유저의 경우 임시로 accessToken 빈 스트링 부여 | ||
// 자동로그인 시 활용하기 위함 | ||
UserDefaultKeyList.Auth.appAccessToken = "" | ||
Comment on lines
+41
to
+43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍🏻이제 잘 동작하겠군요 |
||
return Fail(error: error).eraseToAnyPublisher() | ||
}) | ||
.map { entity in | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,6 @@ import Core | |
import Combine | ||
|
||
public protocol MainRepositoryInterface { | ||
func getUserMainInfo() -> AnyPublisher<UserMainInfoModel?, Error> | ||
func getUserMainInfo() -> AnyPublisher<UserMainInfoModel?, Never> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 에러 핸들링을 하게 된다면 여기에 Never로 적힌 것도 새로 정의한 Error로 바꾸는게 맞을까요? |
||
func getServiceState() -> AnyPublisher<ServiceStateModel, Error> | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// | ||
// APIError.swift | ||
// Network | ||
// | ||
// Created by Junho Lee on 2023/04/21. | ||
// Copyright © 2023 SOPT-iOS. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public enum APIError: Error, Equatable { | ||
case network(statusCode: Int) | ||
case unknown | ||
case tokenReissuanceFailed | ||
|
||
init(error: Error, statusCode: Int? = 0) { | ||
guard let statusCode else { self = .unknown ; return } | ||
|
||
self = .network(statusCode: statusCode) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
withError로 임시 처리를 했지만 결국 Error 타입을 제대로 정의해서 핸들링 하는 것이 맞다고 생각해요!
레포지토리에서 APIError 열거형을 사용하여 네트워크 에러가 발생한경우를 잡아내고 플그 미등록 유저인 경우도 이 열거형을 통해 구분하는 것이 맞을까요? 아니면 APIError가 아닌 새로운 열거형을 생성해서 에러 처리를 하는 것이 좋을까요?