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

๐Ÿ›  oauth ๋กœ๊ทธ์ธ ๊ณ„์ • ์กด์žฌ ์—ฌ๋ถ€ ํŒ๋‹จ/๊ธฐํƒ€ ์ˆ˜์ • ์‚ฌํ•ญ #67

Merged
merged 4 commits into from
Jan 16, 2024

Conversation

heejinnn
Copy link
Collaborator

์ž‘์—… ์ด์œ 

  • kakao, google oauth ๋กœ๊ทธ์ธ ๊ธฐ์กด๊ณ„์ •/์‹ ๊ทœ๊ณ„์ • ์—ฌ๋ถ€ ํŒŒ์•…
  • oauth ๋กœ๊ทธ์ธ์‹œ ๋ฐ˜ํ™˜๋˜๋Š” userId ๊ฐ’ ์ฒ˜๋ฆฌ
  • oauth ๋กœ๊ทธ์ธ์‹œ ์œ ์ € ์ •๋ณด ์กฐํšŒ api ์‹คํ–‰๋˜์ง€ ์•Š๋Š” ๋ฌธ์ œ ํ•ด๊ฒฐ

์ž‘์—… ์‚ฌํ•ญ

  • ๋กœ๊ทธ์ธ๋œ ๊ฒฝ์šฐ ์œ ์ € ์ •๋ณด ์กฐํšŒ api ๋น„๋™๊ธฐ๋กœ ๋ฐ”๋กœ ์š”์ฒญ -> mainVC ํ™”๋ฉด load์‹œ ์œ ์ € ์ •๋ณด ์กฐํšŒ api ์‹คํ–‰์œผ๋กœ ๋ณ€๊ฒฝ

1๏ธโƒฃ ๊ธฐ์กด ๊ณ„์ • ์กด์žฌํ•˜๋Š” ๊ฒฝ์šฐ

  • {"status":"success","data":{"userId":{user_id}}
  • "userId" ํ•„๋“œ๊ฐ€ ์žˆ๋Š” ๊ฒฝ์šฐ ๊ธฐ์กด ๊ณ„์ •์ด ์žˆ๋Š” ์œ ์ €๋กœ ํŒ๋‹จ

2๏ธโƒฃ ์‹ ๊ทœ ๊ณ„์ •์ธ ๊ฒฝ์šฐ

  • {"status":"success","data":{"id":{oauth_id}}

3๏ธโƒฃ ๋ณ€๊ฒฝ ์ฝ”๋“œ

  • url : fitapet.co.kr:8080/api/v1/auth/oauth
AnonymousAlamofire.shared.oauthLogin(){
    result in
    switch result {
    case .success(let data):
        if let responseData = data {
            let object = try?JSONSerialization.jsonObject(with: responseData, options: []) as? NSDictionary
            guard let jsonObject = object else {return}
            print("respose jsonData: \(jsonObject)")
            if let userData = jsonObject["data"] as? [String: Any], let userId = userData["userId"] as? Int {
                UserDefaults.standard.set(userId, forKey: "id")
                self.present(mainVC, animated: false, completion: nil)
            } else {
                RegistDivision.oauth = true
                self.navigationController?.pushViewController(nextVC, animated: false)
            }
        }
    case .failure(let error):
        print("Error: \(error)")
    }
}

์ด์Šˆ ์—ฐ๊ฒฐ

#12
#40
#42

@heejinnn heejinnn self-assigned this Jan 16, 2024
Copy link
Member

@psychology50 psychology50 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ํ”„๋ก ํŠธ ๋ง›์ง‘. ๊ตฌ๊ฒฝ ์ž˜ ํ•˜๊ณ  ๊ฐ‘๋‹ˆ๋‹ค.

@psychology50 psychology50 merged commit 9af48cb into develop Jan 16, 2024
3 checks passed
@psychology50 psychology50 deleted the feat/12 branch January 16, 2024 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants