Skip to content

Commit

Permalink
feat: oauth 로그인시 userId 반환 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
heejinnn committed Jan 16, 2024
1 parent 54e6e53 commit c4adbe6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Binary file not shown.
18 changes: 13 additions & 5 deletions fit-a-pet-client/fit-a-pet-client/ViewControllers/FirstVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,13 @@ extension FirstVC{
let object = try?JSONSerialization.jsonObject(with: responseData, options: []) as? NSDictionary
guard let jsonObject = object else {return}
print("respose jsonData: \(jsonObject)")
if let dataValue = jsonObject["data"], dataValue is NSNull {
if let userData = jsonObject["data"] as? [String: Any], let userId = userData["userId"] as? Int {
print("User ID: \(userId)")
UserDefaults.standard.set(userId, forKey: "id")

self.present(mainVC, animated: false, completion: nil)
}else{
} else {

RegistDivision.oauth = true
self.navigationController?.pushViewController(nextVC, animated: false)
}
Expand Down Expand Up @@ -278,10 +282,14 @@ extension FirstVC{
let object = try?JSONSerialization.jsonObject(with: responseData, options: []) as? NSDictionary
guard let jsonObject = object else {return}
print("respose jsonData: \(jsonObject)")

if let dataValue = jsonObject["data"], dataValue is NSNull {

if let userData = jsonObject["data"] as? [String: Any], let userId = userData["userId"] as? Int {
print("User ID: \(userId)")
UserDefaults.standard.set(userId, forKey: "id")

self.present(mainVC, animated: false, completion: nil)
}else{
} else {

RegistDivision.oauth = true
self.navigationController?.pushViewController(nextVC, animated: false)
}
Expand Down

0 comments on commit c4adbe6

Please sign in to comment.