Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Poppool/Poppool.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
08B191BA2CF609AE0057BC04 /* RxKakaoSDK in Frameworks */ = {isa = PBXBuildFile; productRef = 08B191B92CF609AE0057BC04 /* RxKakaoSDK */; };
08B191BC2CF609AE0057BC04 /* RxKakaoSDKAuth in Frameworks */ = {isa = PBXBuildFile; productRef = 08B191BB2CF609AE0057BC04 /* RxKakaoSDKAuth */; };
08B191BE2CF609AE0057BC04 /* RxKakaoSDKUser in Frameworks */ = {isa = PBXBuildFile; productRef = 08B191BD2CF609AE0057BC04 /* RxKakaoSDKUser */; };
08B191C22CF615CA0057BC04 /* Secrets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08B191C12CF615CA0057BC04 /* Secrets.swift */; };
BD9103612CF6149D00BBCCAE /* AuthAPIEndPoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD91034E2CF6149D00BBCCAE /* AuthAPIEndPoint.swift */; };
BD9103622CF6149D00BBCCAE /* LoginResponseDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD91034F2CF6149D00BBCCAE /* LoginResponseDTO.swift */; };
BD9103632CF6149D00BBCCAE /* BannerPopUpStoreDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD9103512CF6149D00BBCCAE /* BannerPopUpStoreDTO.swift */; };
Expand Down Expand Up @@ -245,6 +246,7 @@
08B191B32CF609260057BC04 /* KakaoLoginService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KakaoLoginService.swift; sourceTree = "<group>"; };
08B191B52CF6092B0057BC04 /* AppleLoginService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppleLoginService.swift; sourceTree = "<group>"; };
08B191B72CF6092F0057BC04 /* AuthServiceable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AuthServiceable.swift; sourceTree = "<group>"; };
08B191C12CF615CA0057BC04 /* Secrets.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Secrets.swift; sourceTree = "<group>"; };
BD91034E2CF6149D00BBCCAE /* AuthAPIEndPoint.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AuthAPIEndPoint.swift; sourceTree = "<group>"; };
BD91034F2CF6149D00BBCCAE /* LoginResponseDTO.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoginResponseDTO.swift; sourceTree = "<group>"; };
BD9103512CF6149D00BBCCAE /* BannerPopUpStoreDTO.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BannerPopUpStoreDTO.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -339,6 +341,7 @@
083A256C2CF361210099B58E /* Resource */ = {
isa = PBXGroup;
children = (
08B191C12CF615CA0057BC04 /* Secrets.swift */,
08B191532CF41D6F0057BC04 /* PP_loading.json */,
08B191542CF41D6F0057BC04 /* PP_splash.json */,
08B1914A2CF41D680057BC04 /* Font */,
Expand Down Expand Up @@ -1057,6 +1060,7 @@
08B191B82CF6092F0057BC04 /* AuthServiceable.swift in Sources */,
BDCA41C52CF35AC0005EECF6 /* TestViewController.swift in Sources */,
BD9103822CF614A900BBCCAE /* SignUpUseCase.swift in Sources */,
08B191C22CF615CA0057BC04 /* Secrets.swift in Sources */,
083A258C2CF361F90099B58E /* ControllerConvention.swift in Sources */,
08B191982CF4A1010057BC04 /* SignUpStep4Reactor.swift in Sources */,
08B1919E2CF4A7830057BC04 /* TagSectionCell.swift in Sources */,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Poppool/Poppool/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import RxKakaoSDKCommon
class AppDelegate: UIResponder, UIApplicationDelegate {

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
RxKakaoSDK.initSDK(appKey: "", loggingEnable: false)
RxKakaoSDK.initSDK(appKey: Secrets.kakaoAuthAppkey.rawValue, loggingEnable: false)
return true
}

Expand Down
3 changes: 2 additions & 1 deletion Poppool/Poppool/Data/Network/AuthAPI/AuthAPIEndPoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ struct PopPoolAPIEndPoint {
baseURL: Secrets.popPoolBaseUrl.rawValue,
path: "/auth/\(path)",
method: .post,
bodyParameters: userCredential
bodyParameters: userCredential,
headers: ["Content-Type": "application/json"]
)
}
}
2 changes: 1 addition & 1 deletion Poppool/Poppool/Infrastructure/AuthServiceable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ protocol AuthServiceable: AnyObject {
func fetchUserCredential() -> Observable<AuthServiceResponse>
}

struct AuthServiceResponse {
struct AuthServiceResponse: Encodable {
var idToken: String?
var authorizationCode: String?
var kakaoUserId: Int64?
Expand Down
46 changes: 32 additions & 14 deletions Poppool/Poppool/Presentation/Secne/Login/LoginReactor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ final class LoginReactor: Reactor {

enum Mutation {
case moveToSignUpScene(controller: BaseViewController)
case moveToHomeScene(controller: BaseViewController)
case loadView
}

Expand All @@ -32,6 +33,7 @@ final class LoginReactor: Reactor {

private let kakaoLoginService = KakaoLoginService()
private let appleLoginService = AppleLoginService()
private let authApiUseCase = TryLoginUseCaseImpl(repository: AuthRepositoryImpl(provider: ProviderImpl()))

// MARK: - init
init() {
Expand All @@ -42,38 +44,54 @@ final class LoginReactor: Reactor {
func mutate(action: Action) -> Observable<Mutation> {
switch action {
case .kakaoButtonTapped(let controller):
return loginWithKakao()
return loginWithKakao(controller: controller)
case .appleButtonTapped(let controller):
return loginWithApple()
return loginWithApple(controller: controller)
}
}

func reduce(state: State, mutation: Mutation) -> State {
var newState = state
switch mutation {
case .moveToSignUpScene(let controller):
let signUpController = SignUpMainController()
signUpController.reactor = SignUpMainReactor()
controller.navigationController?.pushViewController(signUpController, animated: true)
case .moveToHomeScene(let controller):
let homeTabbar = BaseViewController()
controller.view.window?.rootViewController = homeTabbar
case .loadView:
print(#function)
}
return newState
return state
}

func loginWithKakao() -> Observable<Mutation> {
kakaoLoginService.fetchUserCredential()
.map { authResponse in
print(authResponse)
return .loadView
func loginWithKakao(controller: BaseViewController) -> Observable<Mutation> {
return kakaoLoginService.fetchUserCredential()
.withUnretained(self)
.flatMap { owner, response in
owner.authApiUseCase.execute(userCredential: response, socialType: "kakao")
}
.map { loginResponse in
if loginResponse.isRegisteredUser {
return .moveToHomeScene(controller: controller)
} else {
return .moveToSignUpScene(controller: controller)
}
}
}

func loginWithApple() -> Observable<Mutation> {
appleLoginService.fetchUserCredential()
.map { authResponse in
print(authResponse)
return .loadView
func loginWithApple(controller: BaseViewController) -> Observable<Mutation> {
return appleLoginService.fetchUserCredential()
.withUnretained(self)
.flatMap { owner, response in
owner.authApiUseCase.execute(userCredential: response, socialType: "apple")
}
.map { loginResponse in
if loginResponse.isRegisteredUser {
return .moveToHomeScene(controller: controller)
} else {
return .moveToSignUpScene(controller: controller)
}
}
}
}
5 changes: 5 additions & 0 deletions Poppool/Poppool/Resource/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
Expand Down