Skip to content

Commit

Permalink
[FEAT] TeamNADA#101 - 로그인 뷰 로직 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
mini-min committed Dec 10, 2021
1 parent 747e279 commit c736dcf
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 30 deletions.
4 changes: 2 additions & 2 deletions NADA-iOS-forRelease.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = T3VFJ764ZC;
DEVELOPMENT_TEAM = 4QG3GC35LA;
INFOPLIST_FILE = "NADA-iOS-forRelease/Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -1218,7 +1218,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = T3VFJ764ZC;
DEVELOPMENT_TEAM = 4QG3GC35LA;
INFOPLIST_FILE = "NADA-iOS-forRelease/Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,12 @@ class LoginViewController: UIViewController {
// MARK: - IBAction Properties
// 카카오톡으로 로그인 버튼 클릭 시
@IBAction func kakaoLoginButton(_ sender: Any) {
// 유효한 토큰 검사
if AuthApi.hasToken() {
if AuthApi.hasToken() { // 유효한 토큰 존재
UserApi.shared.accessTokenInfo { (_, error) in
if let error = error {
if let sdkError = error as? SdkError, sdkError.isInvalidTokenError() == true {
// 로그인 필요
self.signUp()
} else {
// 기타 에러
}
} else {
// 토큰 유효성 체크 성공(필요 시 토큰 갱신됨)
Expand Down Expand Up @@ -72,36 +69,30 @@ extension LoginViewController {
// 카카오톡 설치 여부 확인
if UserApi.isKakaoTalkLoginAvailable() {
// 카카오톡 로그인. api 호출 결과를 클로저로 전달.
UserApi.shared.loginWithKakaoTalk {(oauthToken, error) in
if let error = error { // 예외 처리 (로그인 취소 등)
print(error)
} else { // 로그인 성공했을 때
print("loginWithKakaoTalk() success.")
self.getUserInfo()
// 어세스토큰
// let accessToken = oauthToken?.accessToken

self.goToMain()
}
}
login()
} else {
print("카카오톡 미설치")
// 만약, 카카오톡이 깔려있지 않을 경우에는 웹 브라우저로 카카오 로그인함.
UserApi.shared.loginWithKakaoTalk {(oauthToken, error) in
if let error = error { // 예외 처리 (로그인 취소 등)
print(error)
} else { // 로그인 성공했을 때
print("loginWithKakaoTalk() success.")
self.getUserInfo()
// 어세스토큰
// let accessToken = oauthToken?.accessToken
self.goToMain()

}
}

func login() {
UserApi.shared.loginWithKakaoTalk {(oauthToken, error) in
if let error = error {
print(error)
} else {
print("loginWithKakaoTalk() success.")
if let kakaoData = oauthToken {

}
}
}

}

// 사용자 정보를 성공적으로 가져왔을 때, 화면전환하는 함수
private func getUserInfo() {
func getUserInfo() {
// 사용자 정보 가져오기
UserApi.shared.me() {(user, error) in
if let error = error {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ extension MoreViewController: UITableViewDelegate {
case 2:
print("회원탈퇴!")
// TODO: - 회원탈퇴 서버 전, alert 창이나 별도의 알림 필요, 수정 요함
// deleteUserWithAPI(userID: "nada3")
deleteUserWithAPI(userID: "2alswo7@naver.com")
default: print("default!")
}
}
Expand Down Expand Up @@ -146,7 +146,6 @@ extension MoreViewController: UITableViewDataSource {

// MARK: - Network
extension MoreViewController {
// FIXME: - 계정 탈퇴 네트워크 함수 추후 위치 수정
func deleteUserWithAPI(userID: String) {
UserAPI.shared.userDelete(userID: userID) { response in
switch response {
Expand Down

0 comments on commit c736dcf

Please sign in to comment.