Skip to content

Commit

Permalink
Merge pull request #318 from OMZigak/hotfix/#297-revokeCode
Browse files Browse the repository at this point in the history
[hotfix] auth_code 발금
  • Loading branch information
hooni0918 authored Aug 22, 2024
2 parents dad76c7 + 3028dcb commit 17b44a7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 29 deletions.
2 changes: 1 addition & 1 deletion KkuMulKum/Application/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
loginViewModel.autoLogin { [weak self] success in
DispatchQueue.main.async {
if success {
self?.showMainScreen()
self?.showLoginScreen()
} else {
self?.showLoginScreen()
}
Expand Down
34 changes: 21 additions & 13 deletions KkuMulKum/Source/Onboarding/Login/VIewModel/LoginViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -289,19 +289,27 @@ class LoginViewModel: NSObject {

extension LoginViewModel: ASAuthorizationControllerDelegate, ASAuthorizationControllerPresentationContextProviding {
func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization) {
print("Apple authorization completed")
guard let appleIDCredential = authorization.credential as? ASAuthorizationAppleIDCredential,
let identityToken = appleIDCredential.identityToken,
let tokenString = String(data: identityToken, encoding: .utf8) else {
print("Failed to get Apple ID Credential or identity token")
return
}

print("Apple Login Successful, identity token: \(tokenString)")
getFCMToken { [weak self] fcmToken in
self?.loginToServer(with: .appleLogin(identityToken: tokenString, fcmToken: fcmToken))
}
}
print("Apple authorization completed")
guard let appleIDCredential = authorization.credential as? ASAuthorizationAppleIDCredential,
let identityToken = appleIDCredential.identityToken,
let tokenString = String(data: identityToken, encoding: .utf8) else {
print("Failed to get Apple ID Credential or identity token")
return
}

// authorization_code 출력 추가
if let authorizationCode = appleIDCredential.authorizationCode,
let codeString = String(data: authorizationCode, encoding: .utf8) {
print("Authorization Code: \(codeString)")
} else {
print("Authorization Code not available")
}

print("Apple Login Successful, identity token: \(tokenString)")
getFCMToken { [weak self] fcmToken in
self?.loginToServer(with: .appleLogin(identityToken: tokenString, fcmToken: fcmToken))
}
}

func authorizationController(controller: ASAuthorizationController, didCompleteWithError error: Error) {
print("Apple authorization error: \(error.localizedDescription)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,21 @@ class LoginViewController: BaseViewController {
}

private func bindViewModel() {
loginViewModel.loginState.bind(with: self) { owner, state in

Task {
switch state {
case .notLogin:
print("Login State: Not logged in")
case .login:
print("Login State: Logged in")
await owner.navigateToMainScreen()
case .needOnboarding:
print("Login State: Need onboarding")
await owner.navigateToOnboardingScreen()
}
}
}
// loginViewModel.loginState.bind(with: self) { owner, state in
//
// Task {
// switch state {
// case .notLogin:
// print("Login State: Not logged in")
// case .login:
// print("Login State: Logged in")
// await owner.navigateToOnboardingScreen()
// case .needOnboarding:
// print("Login State: Need onboarding")
// await owner.navigateToOnboardingScreen()
// }
// }
// }

loginViewModel.userName.bind(with: self) { owner, name in
Task {
Expand Down

0 comments on commit 17b44a7

Please sign in to comment.