Skip to content

Commit

Permalink
[Feat] - DDD-Community#44 UserID 저장 로직 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
sunny5875 committed Feb 3, 2025
1 parent 4dade92 commit b6458b4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
12 changes: 7 additions & 5 deletions Projects/App/Sources/Root/RootStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import Foundation

import CoreDomain
import Feature

import ComposableArchitecture
Expand All @@ -25,7 +26,6 @@ public struct RootStore {
}
}


@Dependency(\.socialLogin) private var socialLogin

public enum Action {
Expand All @@ -45,21 +45,23 @@ public struct RootStore {
case .splash(.routeToMainTabScreen):
state = .mainTab(.init(.home))
return .none

case let .login(.loginSuccess(user)):
debugPrint(user)
fallthrough

case .splash(.routeToOnboardingScreen), .login(.routeToOnboardingScreen):
state = .onboarding(OnboardingRootStore.State())
return .none



case .onboarding(.onSuccessSignUp):
state = .mainTab(.init(.home))
return .none

case .mainTab(.routeToLoginPage):
// TODO: - 로그인 페이지로 이동하도록 변경
state = .onboarding(.init())
state = .login(.init())
return .none

case let .onOpenURL(url):
socialLogin.handleKakaoUrl(url)
return .none
Expand Down
5 changes: 4 additions & 1 deletion Projects/Feature/Login/Sources/LoginStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public struct LoginStore {
}

@Dependency(\.socialLogin) private var socialLogin
@Dependency(KeychainClient.self) var keychainClient

public var body: some ReducerOf<Self> {
Reduce { state,action in
Expand Down Expand Up @@ -75,7 +76,9 @@ public struct LoginStore {
case let .loginSuccess(user):
state.isLoggedIn = true
state.user = user
return .none
return .run { [user = user] send in
keychainClient.setUserID(user.userID)
}

case .loginFailure:
return .none
Expand Down
4 changes: 2 additions & 2 deletions Projects/Feature/Splash/Sources/SplashStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public struct SplashStore {
state.userInfo = userInfo
return .send(.routeToMainTabScreen)
case .fetchUser(.failure):
return .send(.routeToLoginScreen)
return .send(.routeToOnboardingScreen)
}
}
}
Expand All @@ -60,7 +60,7 @@ public struct SplashStore {
return requestFetchUser()
} else {
return .send(.routeToLoginScreen)
}
}
}

private func requestFetchUser() -> Effect<Action> {
Expand Down

0 comments on commit b6458b4

Please sign in to comment.