-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FIX] #246 - 자동 로그인 버그 해결 #251
Conversation
@@ -8,5 +8,5 @@ | |||
import Foundation | |||
|
|||
struct Const { | |||
|
|||
static let headerToken: String = UserDefaults.standard.string(forKey: Const.UserDefaultsKey.accessToken) ?? "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
선배 덕에 도약이야. 크
static var bearerHeader = ["Authorization": "Bearer " + UserDefaults.standard.string(forKey: Const.UserDefaultsKey.accessToken)!] | ||
|
||
static var basicHeader = ["Content-Type": "application/json", | ||
"Authorization": "Bearer " + UserDefaults.standard.string(forKey: Const.UserDefaultsKey.accessToken)!] | ||
"Authorization": "Bearer " + headerToken] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요부분도 동일하게 적용해주어야할거 같아요!
어차피 로그인에서는 basicHeader 만 쓰겠지만 같은 값을 다르게 표시한 부분을 피할 수 있을거 같아요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요부분이라면 bearerHeder 말씀하시는건가요 선배??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵!
static let isAppleLogin = "isAppleLogin" | ||
static let isKakaoLogin = "isKakaoLogin" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좋았다 선배야
// 앱 실행 중 애플 ID 강제로 연결 취소 시 | ||
NotificationCenter.default.addObserver(forName: ASAuthorizationAppleIDProvider.credentialRevokedNotification, object: nil, queue: nil) { (Notification) in | ||
print("Revoked Notification") | ||
self.isLogin = false | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
애플은 이렇게 하면되는데 카카오는 앱에서 연결끊기가 가능하지 카카오에서 연결을 끊으면 알아볼 방법이 없어보여요,,, 일단 전자의 경우 출처임당..
https://developers.kakao.com/docs/latest/ko/kakaologin/ios#unlink
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
맞습니다....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
허허.. 뭔가 근데 애플은 앱에서 연결을 끊는게 없고 애플에서 끊으면 확인하는게 있고 / 카카오는 앱에서 연결을 끊는게 있고 카카오에서 끊은걸 확인하는게 없고 난리부르스네 일단 요거 생각안하구 되는데로 해두고 얘기해보자구요
case .groupReset: | ||
return Const.Header.basicHeader |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
if AuthApi.hasToken() { // 유효한 토큰 존재 | ||
UserApi.shared.accessTokenInfo { (_, error) in | ||
if let error = error { | ||
if let sdkError = error as? SdkError, sdkError.isInvalidTokenError() == true { | ||
// 로그인 필요 | ||
self.signUp() | ||
} | ||
} else { | ||
// 토큰 유효성 체크 성공(필요 시 토큰 갱신됨) | ||
self.signUp() | ||
} | ||
} | ||
// 카카오톡 설치 여부 확인 | ||
if UserApi.isKakaoTalkLoginAvailable() { | ||
// 카카오톡 로그인. api 호출 결과를 클로저로 전달. | ||
loginWithApp() | ||
} else { | ||
// 카카오 토큰 없음 -> 로그인 필요 | ||
self.signUp() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아.. 원래 로직은 버튼 클릭해서 토큰 확인했었군여? 굳굳 깔끔해졌어여
override func viewWillAppear(_ animated: Bool) { | ||
super.viewWillAppear(animated) | ||
|
||
// Do any additional setup after loading the view. | ||
// postUserTokenReissue(request: UserTokenReissueRequset(accessToken: UserDefaults.standard.string(forKey: Const.UserDefaults.accessToken)!, refreshToken: UserDefaults.standard.string(forKey: Const.UserDefaults.refreshToken)!)) | ||
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 1) { | ||
if self.appDelegate?.isLogin == true { | ||
self.presentToMain() | ||
} else { | ||
self.presentToLogin() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
쵝오
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
디패큐!!!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LZTM!
override func viewWillAppear(_ animated: Bool) { | ||
super.viewWillAppear(animated) | ||
|
||
// Do any additional setup after loading the view. | ||
// postUserTokenReissue(request: UserTokenReissueRequset(accessToken: UserDefaults.standard.string(forKey: Const.UserDefaults.accessToken)!, refreshToken: UserDefaults.standard.string(forKey: Const.UserDefaults.refreshToken)!)) | ||
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 1) { | ||
if self.appDelegate?.isLogin == true { | ||
self.presentToMain() | ||
} else { | ||
self.presentToLogin() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
디패큐!!!!
|
||
} | ||
|
||
override func viewWillAppear(_ animated: Bool) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
스플래쉬는 좋겠다... 뷰 윌 어피어도 되고... 시무룩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ..ㅜ
🌴 PR 요약
🌱 작업한 브랜치
🌱 작업한 내용
더 좋은 방법이 있을까요..?
일단 지난번에도 보셨겠지만, 옵셔널 바인딩은 안되는거 같더라구요...UserDefaults
추가 -> isKakao, isApple(로그인 어느 것을 선택했는지 구분하기 위함)AppDelegate
)Service
도Const header
를 가져오는 것으로 수정splash
에서 담당하는 것으로 변경 -> 팍하면서 화면 전환되었던 이슈 해결📮 관련 이슈