Skip to content

Commit

Permalink
✨[FEAT] : #139 로그인 이후 화면 처리 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
comeheredart committed Oct 15, 2021
1 parent e48c486 commit 472025b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
6 changes: 2 additions & 4 deletions ChaRo-iOS/ChaRo-iOS/Source/Services/SocialLoginService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,8 @@ struct SocialLoginService {

switch statusCode {

case 200:
return .success(decodedData)
print(decodedData.success)
print(decodedData.data)
case 200, 401:
return .success(decodedData.success)

case 400:
print(decodedData.msg)
Expand Down
25 changes: 20 additions & 5 deletions ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/SignScene/SNSLoginVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class SNSLoginVC: UIViewController {
$0.titleEdgeInsets = UIEdgeInsets(top: 0, left: -40, bottom: 0, right: 0)
$0.layer.cornerRadius = 10
$0.clipsToBounds = true
$0.addTarget(self, action: #selector(appleLogin), for: .touchUpInside)
$0.addTarget(self, action: #selector(testLogin), for: .touchUpInside)
}

let googleLoginBtn = UIButton().then {
Expand Down Expand Up @@ -86,6 +86,10 @@ class SNSLoginVC: UIViewController {
$0.addTarget(self, action: #selector(kakaoLogin), for: .touchUpInside)
}

@objc func testLogin() {
socialLogin(email: "[email protected]")
}

@objc func appleLogin() {
let request = ASAuthorizationAppleIDProvider().createRequest()
request.requestedScopes = [.fullName, .email]
Expand Down Expand Up @@ -172,14 +176,23 @@ class SNSLoginVC: UIViewController {
// }
}

@objc func socialLogin() {
SocialLoginService.shared.socialLogin(email: "[email protected]") { (response) in
@objc func socialLogin(email: String) {
SocialLoginService.shared.socialLogin(email: email) { (response) in

switch(response)
{
case .success(let success):
if let success = success as? Bool {
print(success)
if success {
print("로그인 성공")
let storyboard = UIStoryboard(name: "Tabbar", bundle: nil)
let nextVC = storyboard.instantiateViewController(withIdentifier: TabbarVC.identifier)
nextVC.modalPresentationStyle = .fullScreen
self.present(nextVC, animated: true, completion: nil)
} else {
print("회원가입 갈겨")
}

}
case .requestErr(let message) :
print("requestERR", message)
Expand Down Expand Up @@ -304,9 +317,11 @@ class SNSLoginVC: UIViewController {
extension SNSLoginVC : ASAuthorizationControllerDelegate {
func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization) {
if let credential = authorization.credential as? ASAuthorizationAppleIDCredential {
print(credential.user)
let user = credential.user
print("👨‍🍳 \(user)")
if let email = credential.email {
print("애플 로그인 이메일 : \(email)")
socialLogin(email: email)
}
}
}
Expand Down

0 comments on commit 472025b

Please sign in to comment.