diff --git a/Projects/Domain/AuthDomain/Interface/DTO/Transfer/ReissueTokenTransfer.swift b/Projects/Domain/AuthDomain/Interface/DTO/Transfer/ReissueTokenTransfer.swift index 86cb2b9b..e864b97d 100644 --- a/Projects/Domain/AuthDomain/Interface/DTO/Transfer/ReissueTokenTransfer.swift +++ b/Projects/Domain/AuthDomain/Interface/DTO/Transfer/ReissueTokenTransfer.swift @@ -1,7 +1,7 @@ import Foundation public extension ReissueTokenResponseDTO { - func toDomain() -> Bool { - return authority == .developer + func toDomain() -> ReissueAuthorityEntity { + ReissueAuthorityEntity(authority: authority) } } diff --git a/Projects/Domain/AuthDomain/Interface/DataSource/RemoteAuthDataSource.swift b/Projects/Domain/AuthDomain/Interface/DataSource/RemoteAuthDataSource.swift index d23133d8..b7b625b6 100644 --- a/Projects/Domain/AuthDomain/Interface/DataSource/RemoteAuthDataSource.swift +++ b/Projects/Domain/AuthDomain/Interface/DataSource/RemoteAuthDataSource.swift @@ -3,6 +3,6 @@ import Foundation public protocol RemoteAuthDataSource { func sendAuthCode(req: SendAuthCodeRequestDTO) -> AnyPublisher - func reissueToken() -> AnyPublisher + func reissueToken() -> AnyPublisher func verifyAuthCode(email: String, authCode: String) -> AnyPublisher } diff --git a/Projects/Domain/AuthDomain/Interface/Entity/ReissueAuthorityEntity.swift b/Projects/Domain/AuthDomain/Interface/Entity/ReissueAuthorityEntity.swift new file mode 100644 index 00000000..c8bae182 --- /dev/null +++ b/Projects/Domain/AuthDomain/Interface/Entity/ReissueAuthorityEntity.swift @@ -0,0 +1,9 @@ +import Foundation + +public struct ReissueAuthorityEntity: Equatable { + public let authority: AuthAuthorityType + + public init(authority: AuthAuthorityType) { + self.authority = authority + } +} diff --git a/Projects/Domain/AuthDomain/Interface/Repository/AuthRepository.swift b/Projects/Domain/AuthDomain/Interface/Repository/AuthRepository.swift index d008038e..78a905ee 100644 --- a/Projects/Domain/AuthDomain/Interface/Repository/AuthRepository.swift +++ b/Projects/Domain/AuthDomain/Interface/Repository/AuthRepository.swift @@ -3,7 +3,7 @@ import Foundation public protocol AuthRepository { func sendAuthCode(req: SendAuthCodeRequestDTO) -> AnyPublisher - func reissueToken() -> AnyPublisher + func reissueToken() -> AnyPublisher func verifyAuthCode(email: String, authCode: String) -> AnyPublisher func logout() } diff --git a/Projects/Domain/AuthDomain/Interface/UseCase/ReissueTokenUseCase.swift b/Projects/Domain/AuthDomain/Interface/UseCase/ReissueTokenUseCase.swift index 4b59421f..b547e631 100644 --- a/Projects/Domain/AuthDomain/Interface/UseCase/ReissueTokenUseCase.swift +++ b/Projects/Domain/AuthDomain/Interface/UseCase/ReissueTokenUseCase.swift @@ -2,5 +2,5 @@ import Combine import UsersDomainInterface public protocol ReissueTokenUseCase { - func execute() -> AnyPublisher + func execute() -> AnyPublisher } diff --git a/Projects/Domain/AuthDomain/Sources/DataSource/RemoteAuthDataSourceImpl.swift b/Projects/Domain/AuthDomain/Sources/DataSource/RemoteAuthDataSourceImpl.swift index e19f29a5..983c4879 100644 --- a/Projects/Domain/AuthDomain/Sources/DataSource/RemoteAuthDataSourceImpl.swift +++ b/Projects/Domain/AuthDomain/Sources/DataSource/RemoteAuthDataSourceImpl.swift @@ -7,7 +7,7 @@ public final class RemoteAuthDataSourceImpl: BaseRemoteDataSource, Remo request(.sendAuthCode(req)) } - public func reissueToken() -> AnyPublisher { + public func reissueToken() -> AnyPublisher { request(.reissueToken, dto: ReissueTokenResponseDTO.self) .map { $0.toDomain() } .eraseToAnyPublisher() diff --git a/Projects/Domain/AuthDomain/Sources/Repository/AuthRepositoryImpl.swift b/Projects/Domain/AuthDomain/Sources/Repository/AuthRepositoryImpl.swift index 78c32d35..6181d3be 100644 --- a/Projects/Domain/AuthDomain/Sources/Repository/AuthRepositoryImpl.swift +++ b/Projects/Domain/AuthDomain/Sources/Repository/AuthRepositoryImpl.swift @@ -17,7 +17,7 @@ public struct AuthRepositoryImpl: AuthRepository { remoteAuthDataSource.sendAuthCode(req: req) } - public func reissueToken() -> AnyPublisher { + public func reissueToken() -> AnyPublisher { remoteAuthDataSource.reissueToken() } diff --git a/Projects/Domain/AuthDomain/Sources/UseCase/ReissueTokenUseCaseImpl.swift b/Projects/Domain/AuthDomain/Sources/UseCase/ReissueTokenUseCaseImpl.swift index 9e339d34..20de595b 100644 --- a/Projects/Domain/AuthDomain/Sources/UseCase/ReissueTokenUseCaseImpl.swift +++ b/Projects/Domain/AuthDomain/Sources/UseCase/ReissueTokenUseCaseImpl.swift @@ -1,5 +1,4 @@ import AuthDomainInterface -import UsersDomainInterface import Combine public struct ReissueTokenUseCaseImpl: ReissueTokenUseCase { @@ -9,7 +8,7 @@ public struct ReissueTokenUseCaseImpl: ReissueTokenUseCase { self.authRepository = authRepository } - public func execute() -> AnyPublisher { + public func execute() -> AnyPublisher { authRepository.reissueToken() } } diff --git a/Projects/Feature/HomeFeature/Sources/Home/Components/StudentInfoView.swift b/Projects/Feature/HomeFeature/Sources/Home/Components/StudentInfoView.swift index 136aaf32..10dfdc75 100644 --- a/Projects/Feature/HomeFeature/Sources/Home/Components/StudentInfoView.swift +++ b/Projects/Feature/HomeFeature/Sources/Home/Components/StudentInfoView.swift @@ -15,7 +15,7 @@ struct StudentInfoView: View { Text("\(studentInfo?.studentGcn ?? "") \(studentInfo?.studentName ?? "Loading")") .JOBISFont(.body(.body1), color: .Sub.gray70) - Text((studentInfo?.department ?? .common)?.localizedString() ?? "") + Text(studentInfo?.department.localizedString() ?? "") .JOBISFont(.etc(.caption), color: .Sub.gray60) } } diff --git a/Projects/Feature/SplashFeature/Sources/SplashView.swift b/Projects/Feature/SplashFeature/Sources/SplashView.swift index f0c12f99..21579205 100644 --- a/Projects/Feature/SplashFeature/Sources/SplashView.swift +++ b/Projects/Feature/SplashFeature/Sources/SplashView.swift @@ -18,45 +18,6 @@ struct SplashView: View { .resizable() .frame(width: 200, height: 200) } - .alert(isPresented: $viewModel.showUpdateAlert) { - if viewModel.forceAlert { - return Alert( - title: Text(viewModel.alertTitle), - message: Text(viewModel.alertMessage), - dismissButton: Alert.Button.destructive( - Text("확인"), - action: { - viewModel.openAppStore() - } - ) - ) - } else { - let reissue: () -> Void = { - viewModel.compareRefreshToke { authority in - appState.authority = authority - appState.sceneFlow = .main - } onError: { _ in - appState.sceneFlow = .auth - } - } - - return Alert( - title: Text(viewModel.alertTitle), - message: Text(viewModel.alertMessage), - primaryButton: Alert.Button.destructive( - Text("확인"), - action: { - viewModel.openAppStore() - reissue() - } - ), - secondaryButton: Alert.Button.cancel( - Text("취소"), - action: reissue - ) - ) - } - } .onAppear { viewModel.onAppear { authority in appState.authority = authority diff --git a/Projects/Feature/SplashFeature/Sources/SplashViewModel.swift b/Projects/Feature/SplashFeature/Sources/SplashViewModel.swift index 0ef23287..5c795b77 100644 --- a/Projects/Feature/SplashFeature/Sources/SplashViewModel.swift +++ b/Projects/Feature/SplashFeature/Sources/SplashViewModel.swift @@ -1,16 +1,10 @@ import BaseFeature -import UIKit import Combine import AuthDomainInterface import UsersDomainInterface final class SplashViewModel: BaseViewModel { private let reissueTokenUseCase: any ReissueTokenUseCase - @Published var showUpdateAlert: Bool = false - @Published var forceAlert: Bool = false - public var alertTitle = "" - public var alertMessage = "" - private let appleID = "6450888392" public init( reissueTokenUseCase: any ReissueTokenUseCase @@ -21,71 +15,15 @@ final class SplashViewModel: BaseViewModel { func onAppear( onSuccess: @escaping (AuthorityType) -> Void, onError: @escaping (Error) -> Void - ) { - update { - self.compareRefreshToke(onSuccess: onSuccess, onError: onError) - } - } - - func compareRefreshToke( - onSuccess: @escaping (AuthorityType) -> Void, - onError: @escaping (Error) -> Void ) { addCancellable(reissueTokenUseCase.execute()) { authority in - if authority { - onSuccess(.developer) + if authority.authority == .developer || authority.authority == .student { + onSuccess(AuthorityType(rawValue: authority.authority.rawValue) ?? .student) } else { - onSuccess(.student) + onError(AuthDomainError.internalServerError) } } onReceiveError: { error in onError(error) } } - - private func update(action: @escaping () -> Void) { - let appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String - let urlString = "http://itunes.apple.com/lookup?id=\(self.appleID)&country=kr" - - guard appVersion != "0.0.0" else { return action() } - guard let url = URL(string: urlString) else { return } - let urlRequest = URLRequest(url: url) - URLSession.shared.dataTask(with: urlRequest) { data, _, _ in - guard let json = try? JSONSerialization.jsonObject(with: data!, options: .allowFragments) as? [String: Any], - let results = json["results"] as? [[String: Any]], - let marketingVersion = results[0]["version"] as? String else { return } - let currentProjectVersion = appVersion! - let splitMarketingVersion = marketingVersion.split(separator: ".").map {$0} - let splitCurrentProjectVersion = currentProjectVersion.split(separator: ".").map {$0} - guard Int(currentProjectVersion.filter { $0 != "."})! < Int(marketingVersion.filter { $0 != "."})! else { - return action() - } - - DispatchQueue.main.async { - self.alertTitle = "업데이트 알림" - self.alertMessage = """ -JOBIS의 새로운 버전이 있습니다. -\(marketingVersion) 버전으로 업데이트 해주세요. -(현 버전: \(currentProjectVersion)) -""" - if splitCurrentProjectVersion[0] < splitMarketingVersion[0] || - splitCurrentProjectVersion[1] < splitMarketingVersion[1] { - self.forceAlert.toggle() - self.showUpdateAlert.toggle() - } else if splitCurrentProjectVersion[2] < splitMarketingVersion[2] { - self.showUpdateAlert.toggle() - } else { - action() - } - } - } - .resume() - } - - func openAppStore() { - let appStoreOpenUrlString = "itms-apps://itunes.apple.com/app/apple-store/\(appleID)" - guard let url = URL(string: appStoreOpenUrlString) else { return } - if UIApplication.shared.canOpenURL(url) { - UIApplication.shared.open(url, options: [:], completionHandler: nil) - } - } }