Skip to content

Commit

Permalink
✨[FEAT] : #139 구글 소셜 회원가입 진짜 성공
Browse files Browse the repository at this point in the history
  • Loading branch information
comeheredart committed Nov 22, 2021
1 parent 87fad4f commit db4a894
Showing 1 changed file with 47 additions and 7 deletions.
54 changes: 47 additions & 7 deletions ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/SignScene/SNSLoginVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class SNSLoginVC: UIViewController {

@objc func testLogin() {
snsType = "A"
socialLogin(email: "[email protected]")
socialLogin(email: "[email protected]", profileImage: nil, nickname: nil)
}

@objc func appleLogin() {
Expand All @@ -108,9 +108,19 @@ class SNSLoginVC: UIViewController {
snsType = "G"
GIDSignIn.sharedInstance.signIn(with: signInConfig, presenting: self) { user, error in
guard error == nil else { return }
print("로긘 성공")
print("구글 로긘 성공")
let userEmail = user?.profile?.email

//여기 유저 이미지 ... String 으로 변환
// do {
// var userProfileImageString = try String(contentsOf: URL(string: (user?.profile?.imageURL(withDimension: 320)!)!)!)
// }
// catch let error {
// print("URL 인코딩 에러")
// }
print("사용자 이메일은 \(userEmail)")

self.socialLogin(email: "[email protected]", profileImage: nil, nickname: nil)
}
}

Expand All @@ -134,7 +144,7 @@ class SNSLoginVC: UIViewController {

}

@objc func socialLogin(email: String) {
@objc func socialLogin(email: String, profileImage: String?, nickname: String?) {
SocialLoginService.shared.socialLogin(email: email) { (response) in

switch(response)
Expand All @@ -146,7 +156,7 @@ class SNSLoginVC: UIViewController {
self.goToHomeVC()
} else {
print("회원가입 갈겨")
self.snsJoin(email: email, profileImage: nil, nickname: nil)
self.snsJoin(email: email, profileImage: profileImage, nickname: nickname)

}

Expand Down Expand Up @@ -209,11 +219,41 @@ class SNSLoginVC: UIViewController {
break

case "G":

print("구글 소셜 회원가입")
SocialJoinService.shared.googleJoin(email: email,
profileImage: "",
pushAgree: isPushAgree!,
emailAgree: isEmailAgree!) { result in


switch result {

case .success(let data):
if let personData = data as? UserInitialInfo {
print("출력한다")
print(personData.email)
print(personData.nickname)
print(personData.profileImage)
}
self.navigationController?.popViewController(animated: true)
self.goToHomeVC()


case .requestErr(let msg):
print("requestERR", msg)
case .pathErr:
print("pathERR")
case .serverErr:
print("serverERR")
case .networkFail:
print("networkFail")
}

}
break

case "K":

//여기서 nickname 인자까지 넣은 snsJoin 날리면 됨
break

default:
Expand Down Expand Up @@ -343,7 +383,7 @@ extension SNSLoginVC : ASAuthorizationControllerDelegate {
let user = credential.user
print("👨‍🍳 \(user)")
if let email = credential.email {
socialLogin(email: email)
socialLogin(email: email, profileImage: nil, nickname: nil)
}
}
}
Expand Down

0 comments on commit db4a894

Please sign in to comment.