Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] 로그인 로직 수정, 유저디폴트 #246

Merged
merged 9 commits into from
Jun 24, 2022
4 changes: 0 additions & 4 deletions ChaRo-iOS/ChaRo-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,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 */; };
Expand Down Expand Up @@ -488,7 +487,6 @@
70D63E37269646D30036484B /* ThemePostAllTVC.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ThemePostAllTVC.xib; sourceTree = "<group>"; };
70F5D7B8271D954F00FF9229 /* SNSJoinVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SNSJoinVC.swift; sourceTree = "<group>"; };
70F5D7BA271D9DBB00FF9229 /* SocialJoinService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SocialJoinService.swift; sourceTree = "<group>"; };
70F5D7BE271DAF8F00FF9229 /* LoginJoinResponseDataModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginJoinResponseDataModel.swift; sourceTree = "<group>"; };
70FD425828170A1B00631BB7 /* ChangePasswordVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChangePasswordVC.swift; sourceTree = "<group>"; };
70FD425A28170A2B00631BB7 /* ChangeImageVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChangeImageVC.swift; sourceTree = "<group>"; };
70FD425C281710C600631BB7 /* UpdatePasswordService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpdatePasswordService.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -917,7 +915,6 @@
36FB8BA427777DF900C2E642 /* DoFollowDataModel.swift */,
7062C848270CC04500C1CD2E /* ValidationEmailModel.swift */,
7062C8582710DCC800C1CD2E /* JoinDataModel.swift */,
70F5D7BE271DAF8F00FF9229 /* LoginJoinResponseDataModel.swift */,
367B318A274A725C007A2C18 /* MypageInfinityDataModel.swift */,
368EC8ED277A16700076BF5E /* GetFollowDataModel.swift */,
36E445BA277CD6A2008E31BE /* SettingViewDataModel.swift */,
Expand Down Expand Up @@ -1859,7 +1856,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 */,
Expand Down
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
10 changes: 10 additions & 0 deletions ChaRo-iOS/ChaRo-iOS/Source/Models/JoinDataModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
20 changes: 0 additions & 20 deletions ChaRo-iOS/ChaRo-iOS/Source/Models/LoginJoinResponseDataModel.swift

This file was deleted.

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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 30 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 @@ -21,7 +22,36 @@ extension Constants {

//소셜 로그인 구분
static let isAppleLogin = "isAppleLogin"
static let savedAppleEmail = "savedAppleEmail"

static let isKakaoLogin = "isKakaoLogin"
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)
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 @@ -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) ?? "[email protected]")", subLabelColor: UIColor.black)]

private var infoInquiryModel = [settingDataModel(titleString: "공지사항", titleLabelColor: UIColor.black),
settingDataModel(titleString: "1:1 문의", titleLabelColor: UIColor.black),
Expand Down 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
Loading