From 4d5ed3d69f28d9617c9c0c5861d590e98137fd48 Mon Sep 17 00:00:00 2001 From: Jen Date: Sat, 25 Jun 2022 00:07:12 +0900 Subject: [PATCH 1/6] =?UTF-8?q?[FEAT]=20#235=20=EC=9C=A0=EC=A0=80=EB=94=94?= =?UTF-8?q?=ED=8F=B4=ED=8A=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ChaRo-iOS/ChaRo-iOS.xcodeproj/project.pbxproj | 4 ++-- ChaRo-iOS/ChaRo-iOS/Resource/Info.plist | 1 + ChaRo-iOS/ChaRo-iOS/Source/Services/Contants.swift | 8 ++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ChaRo-iOS/ChaRo-iOS.xcodeproj/project.pbxproj b/ChaRo-iOS/ChaRo-iOS.xcodeproj/project.pbxproj index 877c253f..f57ad82e 100644 --- a/ChaRo-iOS/ChaRo-iOS.xcodeproj/project.pbxproj +++ b/ChaRo-iOS/ChaRo-iOS.xcodeproj/project.pbxproj @@ -2045,7 +2045,7 @@ CODE_SIGN_ENTITLEMENTS = "ChaRo-iOS/ChaRo-iOS.entitlements"; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = 2ZS26WP93H; + DEVELOPMENT_TEAM = J8A843466G; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)", @@ -2077,7 +2077,7 @@ CODE_SIGN_ENTITLEMENTS = "ChaRo-iOS/ChaRo-iOS.entitlements"; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = 2ZS26WP93H; + DEVELOPMENT_TEAM = J8A843466G; "EXCLUDED_ARCHS[sdk=*]" = arm64; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", diff --git a/ChaRo-iOS/ChaRo-iOS/Resource/Info.plist b/ChaRo-iOS/ChaRo-iOS/Resource/Info.plist index 76fbdc5a..47a3e9db 100644 --- a/ChaRo-iOS/ChaRo-iOS/Resource/Info.plist +++ b/ChaRo-iOS/ChaRo-iOS/Resource/Info.plist @@ -86,6 +86,7 @@ fetch remote-notification + voip UILaunchStoryboardName LaunchScreen diff --git a/ChaRo-iOS/ChaRo-iOS/Source/Services/Contants.swift b/ChaRo-iOS/ChaRo-iOS/Source/Services/Contants.swift index 41267643..ee5777e6 100644 --- a/ChaRo-iOS/ChaRo-iOS/Source/Services/Contants.swift +++ b/ChaRo-iOS/ChaRo-iOS/Source/Services/Contants.swift @@ -12,10 +12,10 @@ struct Constants { // MARK: - BASE URL static let baseURL = "http://52.79.108.141:5000" - static let userId = UserDefaults.standard.string(forKey: "userId") ?? "ios@gmail.com" - static let nickName = UserDefaults.standard.string(forKey: "nickname") ?? "지으니" - static let profileName = UserDefaults.standard.string(forKey: "profileImage") ?? "https://charo-image.s3.ap-northeast-2.amazonaws.com/dummy/jieun.JPG" - static let userEmail = UserDefaults.standard.string(forKey: "userEmail") ?? "ios@gmail.com" + static let userId = UserDefaults.standard.string(forKey: Constants.UserDefaultsKey.userEmail) ?? "ios@gmail.com" + static let nickName = UserDefaults.standard.string(forKey: Constants.UserDefaultsKey.userNickname) ?? "지으니" + static let profileName = UserDefaults.standard.string(forKey: Constants.UserDefaultsKey.userImage) ?? "https://charo-image.s3.ap-northeast-2.amazonaws.com/dummy/jieun.JPG" + static let userEmail = UserDefaults.standard.string(forKey: Constants.UserDefaultsKey.userEmail) ?? "ios@gmail.com" // MARK: - Feature URL From 91785bb55101c21df7aaabe0cafb4174c9d62622 Mon Sep 17 00:00:00 2001 From: Jen Date: Sat, 25 Jun 2022 00:13:36 +0900 Subject: [PATCH 2/6] =?UTF-8?q?[FEAT]=20=EC=88=98=EC=A0=95=20=EB=B7=B0=20?= =?UTF-8?q?=EB=B9=84=EB=B0=80=EB=B2=88=ED=98=B8=20=EC=88=98=EC=A0=95?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChaRo-iOS/Source/Views/VCs/SettingScene/SettingVC.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/SettingScene/SettingVC.swift b/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/SettingScene/SettingVC.swift index e0a85225..568275e7 100644 --- a/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/SettingScene/SettingVC.swift +++ b/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/SettingScene/SettingVC.swift @@ -302,8 +302,8 @@ extension SettingVC: UITableViewDataSource { let changeImageVC = ChangeImageVC() self.navigationController?.pushViewController(changeImageVC, animated: true) case 1: - let findPasswordVC = FindPasswordVC() - self.navigationController?.pushViewController(findPasswordVC, animated: true) + let changePasswordVC = ChangePasswordVC() + self.navigationController?.pushViewController(changePasswordVC, animated: true) default: break } From d22ce7674aa8e6235e3ca480efa6e15e8ed0efde Mon Sep 17 00:00:00 2001 From: Jen Date: Sat, 25 Jun 2022 00:41:14 +0900 Subject: [PATCH 3/6] =?UTF-8?q?[FEAT]=20#235=20=EB=A1=9C=EA=B7=B8=EC=95=84?= =?UTF-8?q?=EC=9B=83=20=EC=9C=A0=EC=A0=80=EB=94=94=ED=8F=B4=ED=8A=B8=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChaRo-iOS/Source/Services/UserDefaultKey.swift | 14 ++++++++++++++ .../Source/Views/VCs/SettingScene/SettingVC.swift | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/ChaRo-iOS/ChaRo-iOS/Source/Services/UserDefaultKey.swift b/ChaRo-iOS/ChaRo-iOS/Source/Services/UserDefaultKey.swift index 69868457..c8cc53fb 100644 --- a/ChaRo-iOS/ChaRo-iOS/Source/Services/UserDefaultKey.swift +++ b/ChaRo-iOS/ChaRo-iOS/Source/Services/UserDefaultKey.swift @@ -6,6 +6,7 @@ // import Foundation +import SwiftUI extension Constants { struct UserDefaultsKey { @@ -24,4 +25,17 @@ extension Constants { static let isKakaoLogin = "isKakaoLogin" static let isGoogleLogin = "isGoogleLogin" } + + static func removeAllUserDefaults() { + UserDefaults.standard.removeObject(forKey: Constants.UserDefaultsKey.userEmail) + UserDefaults.standard.removeObject(forKey: Constants.UserDefaultsKey.userPassword) + UserDefaults.standard.removeObject(forKey: Constants.UserDefaultsKey.userNickname) + UserDefaults.standard.removeObject(forKey: Constants.UserDefaultsKey.userImage) + + UserDefaults.standard.removeObject(forKey: Constants.UserDefaultsKey.isLogin) + + UserDefaults.standard.removeObject(forKey: Constants.UserDefaultsKey.isAppleLogin) + UserDefaults.standard.removeObject(forKey: Constants.UserDefaultsKey.isKakaoLogin) + UserDefaults.standard.removeObject(forKey: Constants.UserDefaultsKey.isGoogleLogin) + } } diff --git a/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/SettingScene/SettingVC.swift b/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/SettingScene/SettingVC.swift index 568275e7..e2412093 100644 --- a/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/SettingScene/SettingVC.swift +++ b/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/SettingScene/SettingVC.swift @@ -171,8 +171,9 @@ extension SettingVC { /// LoginSB의 루트 네비게이션 컨트롤러로 화면전환하는 메서드 private func presentToSignNC() { + Constants.removeAllUserDefaults() guard let signNC = UIStoryboard(name: "Login", bundle: nil).instantiateViewController(withIdentifier: SignNC.className) - as? SignNC else {return} + as? SignNC else { return } signNC.modalPresentationStyle = .overFullScreen self.present(signNC, animated: true, completion: nil) } From b9a247b0e2ef99d0f40871edfe6f5ca4c1ce4d60 Mon Sep 17 00:00:00 2001 From: Jen Date: Sat, 25 Jun 2022 01:16:45 +0900 Subject: [PATCH 4/6] =?UTF-8?q?[FEAT]=20#235=20=EB=A7=88=EC=9D=B4=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20=EC=9C=A0=EC=A0=80=EB=94=94=ED=8F=B4?= =?UTF-8?q?=ED=8A=B8=20=EC=88=98=EC=A0=95,=20=EC=9C=A0=EC=A0=80=EB=94=94?= =?UTF-8?q?=ED=8F=B4=ED=8A=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Source/Views/VCs/MyPageScene/MyPageVC.swift | 5 ++--- .../Source/Views/VCs/SignScene/SNSLoginVC.swift | 11 +++++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/MyPageScene/MyPageVC.swift b/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/MyPageScene/MyPageVC.swift index 8cad211b..e1ec6bfb 100644 --- a/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/MyPageScene/MyPageVC.swift +++ b/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/MyPageScene/MyPageVC.swift @@ -18,8 +18,7 @@ class MyPageVC: UIViewController { let userheight = UIScreen.main.bounds.height var tabbarBottomConstraint: Int = 0 -// var isLogin: Bool = UserDefaults.standard.bool(forKey: "isLogin") ?? true - var isLogin: Bool = true + var isLogin: Bool = UserDefaults.standard.bool(forKey: Constants.UserDefaultsKey.isLogin) ?? false private var userProfileData: [UserInformation] = [] //var writenPostData: [MyPagePost] = [] @@ -31,7 +30,7 @@ class MyPageVC: UIViewController { var currentState: String = "인기순" //무한스크롤을 위함 - var myId: String = UserDefaults.standard.string(forKey: "userId") ?? "ios@gmail.com" + var myId: String = UserDefaults.standard.string(forKey: Constants.UserDefaultsKey.userEmail) ?? "ios@gmail.com" var lastId: Int = 0 var lastFavorite: Int = 0 var isLast: Bool = false diff --git a/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/SignScene/SNSLoginVC.swift b/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/SignScene/SNSLoginVC.swift index e1dc99d4..2926b43f 100644 --- a/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/SignScene/SNSLoginVC.swift +++ b/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/SignScene/SNSLoginVC.swift @@ -91,6 +91,7 @@ class SNSLoginVC: UIViewController { @objc func lookAroundButtonClicked() { //isLogin 값을 false로 설정 - 둘러보기이므로 계정 없음 + Constants.removeAllUserDefaults() UserDefaults.standard.set(false, forKey: Constants.UserDefaultsKey.isLogin) self.goToHomeVC() } @@ -118,7 +119,14 @@ class SNSLoginVC: UIViewController { snsType = "G" GIDSignIn.sharedInstance.signIn(with: signInConfig, presenting: self) { user, error in guard error == nil else { return } - let userEmail = user?.profile?.email + + guard let userEmail = user?.profile?.email else { + self.makeAlert(title: "로그인 오류", + message: "선택된 구글 아이디가 없습니다.") + return + } + + self.socialLogin(email: userEmail, profileImage: nil, nickname: nil) //여기 유저 이미지 ... String 으로 변환 모루겟다 // do { // var userProfileImageString = try String(contentsOf: URL(string: (user?.profile?.imageURL(withDimension: 320)!)!)!) @@ -128,7 +136,6 @@ class SNSLoginVC: UIViewController { // } //로그인 - self.socialLogin(email: userEmail!, profileImage: nil, nickname: nil) } } From bc64f3142e83826e720bf425b7f1a6cea64b722c Mon Sep 17 00:00:00 2001 From: Jen Date: Sat, 25 Jun 2022 05:33:58 +0900 Subject: [PATCH 5/6] =?UTF-8?q?[FEAT]=20=EC=9C=A0=EC=A0=80=20=EB=94=94?= =?UTF-8?q?=ED=8F=B4=ED=8A=B8=20=EC=88=98=EC=A0=95,=20=EA=B5=AC=EA=B8=80,?= =?UTF-8?q?=20=EC=B9=B4=EC=B9=B4=EC=98=A4=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ChaRo-iOS/ChaRo-iOS.xcodeproj/project.pbxproj | 6 +- .../Source/Models/JoinDataModel.swift | 10 ++ .../Models/LoginJoinResponseDataModel.swift | 20 ---- .../Source/Services/SocialJoinService.swift | 2 +- .../Source/Services/UserDefaultKey.swift | 2 + .../Source/Views/VCs/HomeScene/HomeVC.swift | 3 + .../Views/VCs/SettingScene/SettingVC.swift | 2 +- .../Views/VCs/SignScene/SNSLoginVC.swift | 104 ++++++++---------- 8 files changed, 62 insertions(+), 87 deletions(-) delete mode 100644 ChaRo-iOS/ChaRo-iOS/Source/Models/LoginJoinResponseDataModel.swift diff --git a/ChaRo-iOS/ChaRo-iOS.xcodeproj/project.pbxproj b/ChaRo-iOS/ChaRo-iOS.xcodeproj/project.pbxproj index 833b0427..a9d3e164 100644 --- a/ChaRo-iOS/ChaRo-iOS.xcodeproj/project.pbxproj +++ b/ChaRo-iOS/ChaRo-iOS.xcodeproj/project.pbxproj @@ -211,7 +211,6 @@ 70D63E39269646D30036484B /* ThemePostAllTVC.xib in Resources */ = {isa = PBXBuildFile; fileRef = 70D63E37269646D30036484B /* ThemePostAllTVC.xib */; }; 70F5D7B9271D954F00FF9229 /* SNSJoinVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70F5D7B8271D954F00FF9229 /* SNSJoinVC.swift */; }; 70F5D7BB271D9DBC00FF9229 /* SocialJoinService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70F5D7BA271D9DBB00FF9229 /* SocialJoinService.swift */; }; - 70F5D7BF271DAF8F00FF9229 /* LoginJoinResponseDataModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70F5D7BE271DAF8F00FF9229 /* LoginJoinResponseDataModel.swift */; }; 70FD425928170A1B00631BB7 /* ChangePasswordVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70FD425828170A1B00631BB7 /* ChangePasswordVC.swift */; }; 70FD425B28170A2B00631BB7 /* ChangeImageVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70FD425A28170A2B00631BB7 /* ChangeImageVC.swift */; }; 70FD425D281710C600631BB7 /* UpdatePasswordService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70FD425C281710C600631BB7 /* UpdatePasswordService.swift */; }; @@ -485,7 +484,6 @@ 70D63E37269646D30036484B /* ThemePostAllTVC.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ThemePostAllTVC.xib; sourceTree = ""; }; 70F5D7B8271D954F00FF9229 /* SNSJoinVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SNSJoinVC.swift; sourceTree = ""; }; 70F5D7BA271D9DBB00FF9229 /* SocialJoinService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SocialJoinService.swift; sourceTree = ""; }; - 70F5D7BE271DAF8F00FF9229 /* LoginJoinResponseDataModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginJoinResponseDataModel.swift; sourceTree = ""; }; 70FD425828170A1B00631BB7 /* ChangePasswordVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChangePasswordVC.swift; sourceTree = ""; }; 70FD425A28170A2B00631BB7 /* ChangeImageVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChangeImageVC.swift; sourceTree = ""; }; 70FD425C281710C600631BB7 /* UpdatePasswordService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpdatePasswordService.swift; sourceTree = ""; }; @@ -911,7 +909,6 @@ 36FB8BA427777DF900C2E642 /* DoFollowDataModel.swift */, 7062C848270CC04500C1CD2E /* ValidationEmailModel.swift */, 7062C8582710DCC800C1CD2E /* JoinDataModel.swift */, - 70F5D7BE271DAF8F00FF9229 /* LoginJoinResponseDataModel.swift */, 367B318A274A725C007A2C18 /* MypageInfinityDataModel.swift */, 368EC8ED277A16700076BF5E /* GetFollowDataModel.swift */, 36E445BA277CD6A2008E31BE /* SettingViewDataModel.swift */, @@ -1851,7 +1848,6 @@ 36CEE5B8269DFA8400974EFF /* DatailDataService.swift in Sources */, 7062C8282704BA5500C1CD2E /* ProfileView.swift in Sources */, 3610A8A02693730700EFC794 /* HomeTodayDriveTVC.swift in Sources */, - 70F5D7BF271DAF8F00FF9229 /* LoginJoinResponseDataModel.swift in Sources */, 3CEC010F269E1C0700E9332C /* Contants.swift in Sources */, 3610A89C2693730700EFC794 /* CommonCVC.swift in Sources */, 36B8B495269B6DB8008DC781 /* HomeDataModel.swift in Sources */, @@ -2077,7 +2073,7 @@ CODE_SIGN_ENTITLEMENTS = "ChaRo-iOS/ChaRo-iOS.entitlements"; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = JCV986BPR5; + DEVELOPMENT_TEAM = J8A843466G; "EXCLUDED_ARCHS[sdk=*]" = arm64; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", diff --git a/ChaRo-iOS/ChaRo-iOS/Source/Models/JoinDataModel.swift b/ChaRo-iOS/ChaRo-iOS/Source/Models/JoinDataModel.swift index 3cb6736e..33152a9e 100644 --- a/ChaRo-iOS/ChaRo-iOS/Source/Models/JoinDataModel.swift +++ b/ChaRo-iOS/ChaRo-iOS/Source/Models/JoinDataModel.swift @@ -8,5 +8,15 @@ import Foundation struct JoinDataModel: Codable { + let success: Bool let msg: String + let data: JoinUserModel +} + +struct JoinUserModel: Codable { + let email: String + let nickname: String + let profileImage: String + let marketingPush: Bool + let marketingEmail: Bool } diff --git a/ChaRo-iOS/ChaRo-iOS/Source/Models/LoginJoinResponseDataModel.swift b/ChaRo-iOS/ChaRo-iOS/Source/Models/LoginJoinResponseDataModel.swift deleted file mode 100644 index 7159aa36..00000000 --- a/ChaRo-iOS/ChaRo-iOS/Source/Models/LoginJoinResponseDataModel.swift +++ /dev/null @@ -1,20 +0,0 @@ -// -// LoginJoinResponseDataModel.swift -// ChaRo-iOS -// -// Created by JEN Lee on 2021/10/18. -// - -import Foundation - -struct LoginJoinResponseDataModel : Codable { - let success: Bool - let msg: String - let data: UserInitialInfo? -} - -struct UserInitialInfo : Codable { - let email: String - let nickname: String - let profileImage: String -} diff --git a/ChaRo-iOS/ChaRo-iOS/Source/Services/SocialJoinService.swift b/ChaRo-iOS/ChaRo-iOS/Source/Services/SocialJoinService.swift index 0bfe50fe..07626d8d 100644 --- a/ChaRo-iOS/ChaRo-iOS/Source/Services/SocialJoinService.swift +++ b/ChaRo-iOS/ChaRo-iOS/Source/Services/SocialJoinService.swift @@ -165,7 +165,7 @@ struct SocialJoinService { let decoder = JSONDecoder() - guard let decodedData = try? decoder.decode(LoginDataModel.self, from: data) + guard let decodedData = try? decoder.decode(JoinDataModel.self, from: data) else { print("패쓰에러") return .pathErr diff --git a/ChaRo-iOS/ChaRo-iOS/Source/Services/UserDefaultKey.swift b/ChaRo-iOS/ChaRo-iOS/Source/Services/UserDefaultKey.swift index c8cc53fb..eadef671 100644 --- a/ChaRo-iOS/ChaRo-iOS/Source/Services/UserDefaultKey.swift +++ b/ChaRo-iOS/ChaRo-iOS/Source/Services/UserDefaultKey.swift @@ -22,6 +22,8 @@ extension Constants { //소셜 로그인 구분 static let isAppleLogin = "isAppleLogin" + static let savedAppleEmail = "savedAppleEmail" + static let isKakaoLogin = "isKakaoLogin" static let isGoogleLogin = "isGoogleLogin" } diff --git a/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/HomeScene/HomeVC.swift b/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/HomeScene/HomeVC.swift index 6f2225f4..76ce0f56 100644 --- a/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/HomeScene/HomeVC.swift +++ b/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/HomeScene/HomeVC.swift @@ -60,6 +60,9 @@ class HomeVC: UIViewController { setActionToSearchButton() navigationController?.isNavigationBarHidden = true HomeTableView.separatorStyle = .none + + print("kami : \(UserDefaults.standard.object(forKey: Constants.UserDefaultsKey.userEmail))") + print("kami : \(UserDefaults.standard.object(forKey: Constants.UserDefaultsKey.userNickname))") } //navigationView diff --git a/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/SettingScene/SettingVC.swift b/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/SettingScene/SettingVC.swift index e2412093..954bbd2a 100644 --- a/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/SettingScene/SettingVC.swift +++ b/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/SettingScene/SettingVC.swift @@ -22,7 +22,7 @@ final class SettingVC: UIViewController { private var accountModel = [settingDataModel(titleString: "프로필 수정", titleLabelColor: UIColor.black), settingDataModel(titleString: "비밀번호 수정", titleLabelColor: UIColor.black), - settingDataModel(titleString: "이메일", titleLabelColor: UIColor.black, isSubLabel: true, subLabelString: Constants.userEmail, subLabelColor: UIColor.black)] + settingDataModel(titleString: "이메일", titleLabelColor: UIColor.black, isSubLabel: true, subLabelString: "\(UserDefaults.standard.object(forKey: Constants.UserDefaultsKey.userEmail) ?? "ios@gmail.com")", subLabelColor: UIColor.black)] private var infoInquiryModel = [settingDataModel(titleString: "공지사항", titleLabelColor: UIColor.black), settingDataModel(titleString: "1:1 문의", titleLabelColor: UIColor.black), diff --git a/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/SignScene/SNSLoginVC.swift b/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/SignScene/SNSLoginVC.swift index 2926b43f..5fbe98b0 100644 --- a/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/SignScene/SNSLoginVC.swift +++ b/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/SignScene/SNSLoginVC.swift @@ -12,13 +12,20 @@ import AuthenticationServices import GoogleSignIn import KakaoSDKUser +enum socialType: String { + case google + case kakao + case apple + case none +} + class SNSLoginVC: UIViewController { let userInfo = UserInfo.shared let signInConfig = GIDConfiguration.init(clientID: "316255098127-usdg37h4sgpondqjh818cl3n002vaach.apps.googleusercontent.com") static let identifier = "SNSLoginVC" - var snsType: String = "DEFAULT" + var socialType: socialType = .none override func viewDidLoad() { super.viewDidLoad() @@ -58,7 +65,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(testLogin), for: .touchUpInside) + $0.addTarget(self, action: #selector(appleLogin), for: .touchUpInside) } let googleLoginBtn = UIButton().then { @@ -97,12 +104,12 @@ class SNSLoginVC: UIViewController { } @objc func testLogin() { - snsType = "A" - socialLogin(email: "yyaggdgggffaa3ao4ng22hh2@naver.com", profileImage: nil, nickname: nil) + socialType = .apple + socialLogin(email: "aggd662@naver.com", profileImage: nil, nickname: nil) } @objc func appleLogin() { - snsType = "A" + socialType = .apple let appleIDProvider = ASAuthorizationAppleIDProvider() let request = appleIDProvider.createRequest() request.requestedScopes = [.fullName, .email] @@ -116,16 +123,11 @@ class SNSLoginVC: UIViewController { @objc func googleLogin() { - snsType = "G" + socialType = .google GIDSignIn.sharedInstance.signIn(with: signInConfig, presenting: self) { user, error in guard error == nil else { return } - guard let userEmail = user?.profile?.email else { - self.makeAlert(title: "로그인 오류", - message: "선택된 구글 아이디가 없습니다.") - return - } - + let userEmail = user?.profile?.email self.socialLogin(email: userEmail, profileImage: nil, nickname: nil) //여기 유저 이미지 ... String 으로 변환 모루겟다 // do { @@ -134,13 +136,11 @@ class SNSLoginVC: UIViewController { // catch let error { // print("URL 인코딩 에러") // } - - //로그인 } } @objc func kakaoLogin() { - snsType = "K" + socialType = .kakao if (UserApi.isKakaoTalkLoginAvailable()) { UserApi.shared.loginWithKakaoTalk {(_, error) in @@ -148,14 +148,11 @@ class SNSLoginVC: UIViewController { print(error) } else { - print("카카오 로긘 성공") UserApi.shared.me() { (user, error) in if let error = error { print(error) } else { - print("me() 성공") - // 닉네임, 이메일 정보 let email = user?.kakaoAccount?.email let nickname = user?.kakaoAccount?.profile?.nickname @@ -167,21 +164,23 @@ class SNSLoginVC: UIViewController { UserDefaults.standard.set(true, forKey: Constants.UserDefaultsKey.isKakaoLogin) //로그인 - self.socialLogin(email: email!, profileImage: nil, nickname: nickname) + self.socialLogin(email: email, profileImage: nil, nickname: nickname) } } - } } } - } - @objc func socialLogin(email: String, profileImage: String?, nickname: String?) { + @objc func socialLogin(email: String?, profileImage: String?, nickname: String?) { + guard let email = email else { + self.makeAlert(title: "오류", message: "이메일이 존재하지 않습니다.") + return + } + SocialLoginService.shared.socialLogin(email: email) { (response) in - switch(response) - { + switch(response) { case .success(let success): if let success = success as? Bool { if success { @@ -195,7 +194,6 @@ class SNSLoginVC: UIViewController { print("회원가입 갈겨") self.snsJoin(email: email, profileImage: profileImage, nickname: nickname) } - } case .requestErr(let message) : print("requestERR", message) @@ -214,25 +212,25 @@ class SNSLoginVC: UIViewController { func snsJoin(email: String, profileImage: String?, nickname: String?) { let storyboard = UIStoryboard(name: "Join", bundle: nil) - let nextVC = storyboard.instantiateViewController(withIdentifier: SNSJoinVC.identifier) as? SNSJoinVC - self.navigationController?.pushViewController(nextVC!, animated: true) + guard let nextVC = storyboard.instantiateViewController(withIdentifier: SNSJoinVC.identifier) as? SNSJoinVC else { return } + self.navigationController?.pushViewController(nextVC, animated: true) - nextVC?.contractView.nextButton.nextPageClosure = { - let isPushAgree = nextVC?.contractView.agreePushButton.Agreed - let isEmailAgree = nextVC?.contractView.agreeEmailButton.Agreed + nextVC.contractView.nextButton.nextPageClosure = { + let isPushAgree = nextVC.contractView.agreePushButton.Agreed + let isEmailAgree = nextVC.contractView.agreeEmailButton.Agreed - switch self.snsType { - case "A": + switch self.socialType { + case .apple: print("애플 소셜 회원가입") SocialJoinService.shared.appleJoin(email: email, - pushAgree: isPushAgree!, - emailAgree: isEmailAgree!) { result in + pushAgree: isPushAgree, + emailAgree: isEmailAgree) { result in switch result { case .success(let data): - if let personData = data as? UserInitialInfo { + if let personData = data as? JoinUserModel { UserDefaults.standard.set(personData.email, forKey: Constants.UserDefaultsKey.userEmail) UserDefaults.standard.set(personData.profileImage, forKey: Constants.UserDefaultsKey.userImage) UserDefaults.standard.set(personData.nickname, forKey: Constants.UserDefaultsKey.userNickname) @@ -254,23 +252,21 @@ class SNSLoginVC: UIViewController { } break - case "G": + case .google: print("구글 소셜 회원가입") SocialJoinService.shared.googleJoin(email: email, profileImage: "", - pushAgree: isPushAgree!, - emailAgree: isEmailAgree!) { result in + pushAgree: isPushAgree, + emailAgree: isEmailAgree) { result in switch result { case .success(let data): - if let personData = data as? UserInitialInfo { - + if let personData = data as? JoinUserModel { UserDefaults.standard.set(personData.email, forKey: Constants.UserDefaultsKey.userEmail) UserDefaults.standard.set(personData.profileImage, forKey: Constants.UserDefaultsKey.userImage) UserDefaults.standard.set(personData.nickname, forKey: Constants.UserDefaultsKey.userNickname) - } self.navigationController?.popViewController(animated: true) self.goToHomeVC() @@ -289,18 +285,18 @@ class SNSLoginVC: UIViewController { } break - case "K": + case .kakao: print("카카오 소셜 회원가입") SocialJoinService.shared.kakaoJoin(email: email, profileImage: "", - pushAgree: isPushAgree!, - emailAgree: isEmailAgree!, + pushAgree: isPushAgree, + emailAgree: isEmailAgree, nickname: nickname!) { result in switch result { case .success(let data): - if let personData = data as? UserInitialInfo { + if let personData = data as? JoinUserModel { UserDefaults.standard.set(personData.email, forKey: Constants.UserDefaultsKey.userEmail) UserDefaults.standard.set(personData.profileImage, forKey: Constants.UserDefaultsKey.userImage) UserDefaults.standard.set(personData.nickname, forKey: Constants.UserDefaultsKey.userNickname) @@ -324,7 +320,7 @@ class SNSLoginVC: UIViewController { break default: - print(self.snsType) + print(self.socialType) break } @@ -449,24 +445,12 @@ extension SNSLoginVC : ASAuthorizationControllerDelegate, ASAuthorizationControl // AppleID 연동 성공 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)") + UserDefaults.standard.set(email, forKey: Constants.UserDefaultsKey.savedAppleEmail) socialLogin(email: email, profileImage: nil, nickname: nil) } } - - // // AppleID 로 로그인 시도 - // case let appleIDCredential as ASAuthorizationAppleIDCredential: - // if let userEmail = appleIDCredential.email { - // socialLogin(email: userEmail, profileImage: nil, nickname: nil) - // } - // - // UserDefaults.standard.set(true, forKey: Constants.UserDefaultsKey.isAppleLogin) - // UserDefaults.standard.set(false, forKey: Constants.UserDefaultsKey.isKakaoLogin) - // UserDefaults.standard.set(false, forKey: Constants.UserDefaultsKey.isGoogleLogin) - // } // AppleID 연동 실패 From 198ff91a07f9b497c65595997536bef3a6e2c602 Mon Sep 17 00:00:00 2001 From: Jen Date: Sat, 25 Jun 2022 06:06:58 +0900 Subject: [PATCH 6/6] =?UTF-8?q?[FEAT]=20#235=20=EC=9C=A0=EC=A0=80=EB=94=94?= =?UTF-8?q?=ED=8F=B4=ED=8A=B8=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Source/Services/UserDefaultKey.swift | 14 ++++++++ .../Views/VCs/SignScene/SNSLoginVC.swift | 34 +++++++++++-------- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/ChaRo-iOS/ChaRo-iOS/Source/Services/UserDefaultKey.swift b/ChaRo-iOS/ChaRo-iOS/Source/Services/UserDefaultKey.swift index eadef671..66cbf4dd 100644 --- a/ChaRo-iOS/ChaRo-iOS/Source/Services/UserDefaultKey.swift +++ b/ChaRo-iOS/ChaRo-iOS/Source/Services/UserDefaultKey.swift @@ -28,6 +28,20 @@ extension Constants { static let isGoogleLogin = "isGoogleLogin" } + static func addLoginUserDefaults(isAppleLogin: Bool, isKakaoLogin: Bool, isGoogleLogin: Bool) { + UserDefaults.standard.set(isAppleLogin, forKey: Constants.UserDefaultsKey.isAppleLogin) + UserDefaults.standard.set(isKakaoLogin, forKey: Constants.UserDefaultsKey.isKakaoLogin) + UserDefaults.standard.set(isGoogleLogin, forKey: Constants.UserDefaultsKey.isGoogleLogin) + } + + static func addUserDefaults(userEmail: String, userPassword: String, userNickname: String, userImage: String) { + UserDefaults.standard.set(userEmail, forKey: Constants.UserDefaultsKey.userEmail) + UserDefaults.standard.set(userPassword, forKey: Constants.UserDefaultsKey.userPassword) + UserDefaults.standard.set(userNickname, forKey: Constants.UserDefaultsKey.userNickname) + UserDefaults.standard.set(userImage, forKey: Constants.UserDefaultsKey.userImage) + UserDefaults.standard.set(true, forKey: Constants.UserDefaultsKey.isLogin) + } + static func removeAllUserDefaults() { UserDefaults.standard.removeObject(forKey: Constants.UserDefaultsKey.userEmail) UserDefaults.standard.removeObject(forKey: Constants.UserDefaultsKey.userPassword) diff --git a/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/SignScene/SNSLoginVC.swift b/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/SignScene/SNSLoginVC.swift index 5fbe98b0..42ee7a8e 100644 --- a/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/SignScene/SNSLoginVC.swift +++ b/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/SignScene/SNSLoginVC.swift @@ -159,9 +159,9 @@ class SNSLoginVC: UIViewController { let profile = user?.kakaoAccount?.profile?.profileImageUrl //여기서도 URL 을 String 으로 바꾸는 법을 모르겠군요 ... - UserDefaults.standard.set(false, forKey: Constants.UserDefaultsKey.isAppleLogin) - UserDefaults.standard.set(false, forKey: Constants.UserDefaultsKey.isGoogleLogin) - UserDefaults.standard.set(true, forKey: Constants.UserDefaultsKey.isKakaoLogin) + Constants.addLoginUserDefaults(isAppleLogin: false, + isKakaoLogin: false, + isGoogleLogin: true) //로그인 self.socialLogin(email: email, profileImage: nil, nickname: nickname) @@ -186,9 +186,10 @@ class SNSLoginVC: UIViewController { if success { print("로그인 성공") //여기서 UserDefault 에 저장 - UserDefaults.standard.set(email, forKey: Constants.UserDefaultsKey.userEmail) - UserDefaults.standard.set(profileImage ?? "", forKey: Constants.UserDefaultsKey.userImage) - UserDefaults.standard.set(nickname ?? "", forKey: Constants.UserDefaultsKey.userNickname) + Constants.addUserDefaults(userEmail: email, + userPassword: "", + userNickname: nickname ?? "", + userImage: profileImage ?? "") self.goToHomeVC() } else { print("회원가입 갈겨") @@ -231,9 +232,10 @@ class SNSLoginVC: UIViewController { case .success(let data): if let personData = data as? JoinUserModel { - UserDefaults.standard.set(personData.email, forKey: Constants.UserDefaultsKey.userEmail) - UserDefaults.standard.set(personData.profileImage, forKey: Constants.UserDefaultsKey.userImage) - UserDefaults.standard.set(personData.nickname, forKey: Constants.UserDefaultsKey.userNickname) + Constants.addUserDefaults(userEmail: personData.email, + userPassword: "", + userNickname: personData.nickname, + userImage: personData.profileImage) } self.navigationController?.popViewController(animated: true) self.goToHomeVC() @@ -264,9 +266,10 @@ class SNSLoginVC: UIViewController { case .success(let data): if let personData = data as? JoinUserModel { - UserDefaults.standard.set(personData.email, forKey: Constants.UserDefaultsKey.userEmail) - UserDefaults.standard.set(personData.profileImage, forKey: Constants.UserDefaultsKey.userImage) - UserDefaults.standard.set(personData.nickname, forKey: Constants.UserDefaultsKey.userNickname) + Constants.addUserDefaults(userEmail: personData.email, + userPassword: "", + userNickname: personData.nickname, + userImage: personData.profileImage) } self.navigationController?.popViewController(animated: true) self.goToHomeVC() @@ -297,9 +300,10 @@ class SNSLoginVC: UIViewController { case .success(let data): if let personData = data as? JoinUserModel { - UserDefaults.standard.set(personData.email, forKey: Constants.UserDefaultsKey.userEmail) - UserDefaults.standard.set(personData.profileImage, forKey: Constants.UserDefaultsKey.userImage) - UserDefaults.standard.set(personData.nickname, forKey: Constants.UserDefaultsKey.userNickname) + Constants.addUserDefaults(userEmail: personData.email, + userPassword: "", + userNickname: personData.nickname, + userImage: personData.profileImage) } self.navigationController?.popViewController(animated: true)