Skip to content

Commit

Permalink
[FIX] #235 충돌해결
Browse files Browse the repository at this point in the history
  • Loading branch information
comeheredart committed Jun 24, 2022
2 parents 54cf3f9 + b9a247b commit 6e518c6
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 12 deletions.
1 change: 1 addition & 0 deletions ChaRo-iOS/ChaRo-iOS/Resource/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
<array>
<string>fetch</string>
<string>remote-notification</string>
<string>voip</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
Expand Down
8 changes: 4 additions & 4 deletions ChaRo-iOS/ChaRo-iOS/Source/Services/Contants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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") ?? "[email protected]"
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") ?? "[email protected]"
static let userId = UserDefaults.standard.string(forKey: Constants.UserDefaultsKey.userEmail) ?? "[email protected]"
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) ?? "[email protected]"


// MARK: - Feature URL
Expand Down
14 changes: 14 additions & 0 deletions ChaRo-iOS/ChaRo-iOS/Source/Services/UserDefaultKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import Foundation
import SwiftUI

extension Constants {
struct UserDefaultsKey {
Expand All @@ -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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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] = []
Expand All @@ -31,7 +30,7 @@ class MyPageVC: UIViewController {
var currentState: String = "인기순"

//무한스크롤을 위함
var myId: String = UserDefaults.standard.string(forKey: "userId") ?? "[email protected]"
var myId: String = UserDefaults.standard.string(forKey: Constants.UserDefaultsKey.userEmail) ?? "[email protected]"
var lastId: Int = 0
var lastFavorite: Int = 0
var isLast: Bool = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -302,8 +303,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
}
Expand Down
11 changes: 9 additions & 2 deletions ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/SignScene/SNSLoginVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class SNSLoginVC: UIViewController {

@objc func lookAroundButtonClicked() {
//isLogin 값을 false로 설정 - 둘러보기이므로 계정 없음
Constants.removeAllUserDefaults()
UserDefaults.standard.set(false, forKey: Constants.UserDefaultsKey.isLogin)
self.goToHomeVC()
}
Expand Down Expand Up @@ -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)!)!)!)
Expand All @@ -128,7 +136,6 @@ class SNSLoginVC: UIViewController {
// }

//로그인
self.socialLogin(email: userEmail!, profileImage: nil, nickname: nil)
}
}

Expand Down

0 comments on commit 6e518c6

Please sign in to comment.