Skip to content

Commit

Permalink
Merge pull request #306 from MaeumGaGym/refactoring/#304-authRefactoring
Browse files Browse the repository at this point in the history
MERGE :: 작업 중지
  • Loading branch information
Eunho0922 authored Apr 22, 2024
2 parents 47a1bef + 1b91843 commit 4b7c8dd
Show file tree
Hide file tree
Showing 16 changed files with 44 additions and 65 deletions.
4 changes: 1 addition & 3 deletions Projects/Data/Sources/Repository/AuthRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class AuthRepository: AuthRepositoryInterface {
public func appleButtonTap() -> Single<String> {
return networkService.appleButtonTap()
}

// repository -> service entity
public func kakaoButtonTap() -> Single<OAuthToken?> {
return networkService.kakaoButtonTap()
}
Expand All @@ -50,8 +50,6 @@ public class AuthRepository: AuthRepositoryInterface {
self.networkService = networkService
}



// public func appleSingup(nickname: String, accessToken: String) -> Single<String> {
// return networkService.appleSignup(nickname: nickname, accessToken: accessToken)
// }
Expand Down
8 changes: 0 additions & 8 deletions Projects/Domain/Sources/UseCase/AuthUseCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,6 @@ extension DefaultAuthUseCase: AuthUseCase {
MGLogger.debug("nicknameButtonTap nickname ✅ \(nicknameText)")

authRepository.oauthSignup(param: SignupRequestDTO(oauthToken: accessToken, nickname: nicknameText), oauth: .apple)
.flatMap { response -> Single<SignupResponseDTO> in
MGLogger.debug(response)
if response.status >= 400 {
return Single.error(AuthErrorType.notFound400)
} else {
return Single.just(response)
}
}
.subscribe(onSuccess: { [self] element in
MGLogger.debug("nicknameButtonTap Signup ✅ \(element)")
authRepository.oauthLogin(param: LoginRequestDTO(oauthToken: accessToken), oauth: .apple)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ import SnapKit
import Then

import Core
import Data
import DSKit

import Domain
import MGLogger
import MGNetworks

import Domain

import BaseFeatureDependency
import AuthenticationServices
Expand Down Expand Up @@ -105,9 +104,6 @@ public class IntroViewController: BaseViewController<IntroViewModel>, Stepper {
public override func bindViewModel() {
super.bindViewModel()

let useCase = DefaultAuthUseCase(authRepository: AuthRepository(networkService: AuthService()))
viewModel = IntroViewModel(authUseCase: useCase)

let input = IntroViewModel.Input(
goolgeButtonTapped: googleButton.rx.tap.asDriver(),
appleButtonTapped: appleButton.rx.tap.asDriver(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import UIKit
import AuthFeatureInterface

import RxSwift
import RxCocoa
Expand All @@ -8,33 +9,18 @@ import SnapKit
import Then

import Core
import Data
import Domain

import MGNetworks

public class SplashViewController: BaseViewController<SplashViewModel>, Stepper {

public var steps = PublishRelay<Step>()

private let iconImageView = UIImageView().then {
$0.image = AuthResourcesService.Assets.splashIcon
}

public override func layout() {
view.addSubviews([iconImageView])

iconImageView.snp.makeConstraints {
$0.centerX.centerY.equalToSuperview()
}
}

public override func bindViewModel() {
super.bindViewModel()

let useCase = DefaultAuthUseCase(authRepository: AuthRepository(networkService: AuthService()))
viewModel = SplashViewModel(authUseCase: useCase)

useCase.splashLogin()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import Moya

import Core
import Domain
import MGNetworks

import KakaoSDKAuth
import KakaoSDKUser
Expand All @@ -25,7 +24,6 @@ public class IntroViewModel: AuthViewModelType {
public var disposeBag: RxSwift.DisposeBag

private let useCase: AuthUseCase

let keychainCSRF = KeychainType.CSRFToken

public struct Input {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import Moya

import Core
import Domain
import MGNetworks

import TokenManager
import AuthFeatureInterface
Expand All @@ -36,9 +35,9 @@ public class SplashViewModel: AuthViewModelType {

let ouput = Output()
action(ouput)
AuthStepper.shared.steps.accept(MGStep.authIntroIsRequired)

useCase.splashLogin()

return Output()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ import Then

import Core
import DSKit
import Data

import Domain
import MGLogger
import MGNetworks

import AuthFeatureInterface

public class AgreeViewController: BaseViewController<AgreeViewModel>, Stepper, UIGestureRecognizerDelegate {

Expand Down Expand Up @@ -139,9 +137,6 @@ public class AgreeViewController: BaseViewController<AgreeViewModel>, Stepper, U
super.bindViewModel()

let navButtonTapped = naviBar.leftButtonTap.asDriver(onErrorDriveWith: .never())
let useCase = DefaultAuthUseCase(authRepository: AuthRepository(networkService: AuthService()))

viewModel = AgreeViewModel(useCase: useCase)

let input = AgreeViewModel.Input(
navButtonTapped: navButtonTapped,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import RxCocoa
import Core
import DSKit

import MGNetworks
import AuthFeatureInterface

final class AuthNavigationBarBar: BaseView {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ import Then

import Core
import DSKit
import Data

import Domain
import MGLogger
import MGNetworks

import AuthFeatureInterface

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import RxFlow

import Core
import Domain
import MGNetworks

public class AgreeViewModel: BaseViewModel {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import Core
import Domain
import MGLogger

import MGNetworks

public class NicknameViewModel: BaseViewModel {

public typealias ViewModel = NicknameViewModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import Core
import RxSwift
import Pickle

import MGNetworks

struct BottomSheetItem {
let icon: UIImage
let title: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import DSKit
import Domain

import MGLogger
import MGNetworks
import Data

import PostureFeatureInterface

Expand Down
26 changes: 18 additions & 8 deletions Projects/Modules/MGNetworks/Sources/Service/AuthService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,19 @@ import KakaoSDKAuth

import AuthenticationServices

public class AuthService: NSObject {
public protocol AuthService {
func nicknameCheck(param: CheckNicknameRequestDTO) -> Single<CheckNicknameResponseDTO>
func tokenRefresh(param: TokenRefreshRequestDTO) -> Single<TokenRefreshResponseDTO>
func oauthSingup(param: SignupRequestDTO, oauth: OauthType) -> Single<SignupResponseDTO>
func oauthLogin(param: LoginRequestDTO, oauth: OauthType) -> Single<LoginResponseDTO>
func oauthRecovery(param: RecoveryRequestDTO, oauth: OauthType) -> Single<RecoveryResponseDTO>
func kakaoButtonTap() -> Single<OAuthToken?>
func requestToken() -> Single<Bool>
func requestIntroData() -> Single<IntroModel>
func appleButtonTap() -> Single<String>
}

public class DefaultAuthService: NSObject {

let kakaoProvider = MoyaProvider<KakaoAPI>()
let googleProvider = MoyaProvider<GoogleAPI>()
Expand All @@ -25,7 +37,9 @@ public class AuthService: NSObject {

private let keychainAuthorization = KeychainType.authorizationToken
private let appleSignupSubject = PublishSubject<String>()

}

extension DefaultAuthService: AuthService {
public func nicknameCheck(param: CheckNicknameRequestDTO) -> Single<CheckNicknameResponseDTO> {
return authProvider.rx.request(.checkNickname(param: param)).map(CheckNicknameResponseDTO.self)
}
Expand Down Expand Up @@ -105,13 +119,9 @@ public class AuthService: NSObject {

return appleSignupSubject.take(1).asSingle()
}

public override init() {

}
}

extension AuthService: ASAuthorizationControllerDelegate {
extension DefaultAuthService: ASAuthorizationControllerDelegate {
public func authorizationController(controller: ASAuthorizationController,
didCompleteWithAuthorization authorization: ASAuthorization
) {
Expand All @@ -132,7 +142,7 @@ extension AuthService: ASAuthorizationControllerDelegate {
}
}

private extension AuthService {
private extension DefaultAuthService {
func googleSignup(param: SignupRequestDTO) -> Single<SignupResponseDTO> {
return googleProvider.rx.request(.googleSignup(param: param))
.map(SignupResponseDTO.self)
Expand Down
File renamed without changes.
14 changes: 14 additions & 0 deletions Supporting/ResourcesService/PickleResourcesService.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import UIKit

import DSKit

public enum PickleResourcesService {
public enum Assets { }
public enum Title {
public static let notSupportingComments = "댓글을 지원하지 않는 영상입니다."
public static let underDevelopment = "아직 개발중입니다!"
}
public enum identifier {
public static let pickleCell = "PickleCell"
}
}

0 comments on commit 4b7c8dd

Please sign in to comment.