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

bug: memberID 요청 전, 토큰을 저장하지 않았던 버그 수정 #313

Merged
merged 2 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions iOS/Layover/Layover/Network/AuthManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ protocol AuthManagerProtocol: AnyObject {
var loginType: LoginType? { get set }
var memberID: Int? { get set }

func login(accessToken: String?, refreshToken: String?, memberID: Int?, loginType: LoginType?)
func login(accessToken: String?, refreshToken: String?, loginType: LoginType?)
func logout()
}

Expand All @@ -23,10 +23,9 @@ enum LoginType: String, Codable {
}

extension AuthManagerProtocol {
func login(accessToken: String?, refreshToken: String?, memberID: Int?, loginType: LoginType?) {
func login(accessToken: String?, refreshToken: String?, loginType: LoginType?) {
self.accessToken = accessToken
self.refreshToken = refreshToken
self.memberID = memberID
self.loginType = loginType
isLoggedIn = true
}
Expand Down
6 changes: 3 additions & 3 deletions iOS/Layover/Layover/Scenes/Login/LoginWorker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ extension LoginWorker: LoginWorkerProtocol {

authManager.login(accessToken: result.data?.accessToken,
refreshToken: result.data?.refreshToken,
memberID: await fetchMemberId(),
loginType: .kakao)
authManager.memberID = await fetchMemberID()
return true
} catch {
os_log(.error, log: .data, "%@", error.localizedDescription)
Expand Down Expand Up @@ -119,16 +119,16 @@ extension LoginWorker: LoginWorkerProtocol {

authManager.login(accessToken: result.data?.accessToken,
refreshToken: result.data?.refreshToken,
memberID: await fetchMemberId(),
loginType: .apple)
authManager.memberID = await fetchMemberID()
return true
} catch {
os_log(.error, log: .data, "%@", error.localizedDescription)
return false
}
}

private func fetchMemberId() async -> Int? {
private func fetchMemberID() async -> Int? {
let endPoint = userEndPointFactory.makeUserInformationEndPoint(with: nil)
do {
let responseData = try await provider.request(with: endPoint)
Expand Down
6 changes: 3 additions & 3 deletions iOS/Layover/Layover/Scenes/SignUpScene/SignUpWorker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ extension SignUpWorker: SignUpWorkerProtocol {

authManager.login(accessToken: data.accessToken,
refreshToken: data.refreshToken,
memberID: await fetchMemberId(),
loginType: .kakao)
authManager.memberID = await fetchMemberID()
return true
} catch {
os_log(.error, log: .data, "Failed to sign up with error: %@", error.localizedDescription)
Expand All @@ -72,16 +72,16 @@ extension SignUpWorker: SignUpWorkerProtocol {
}
authManager.login(accessToken: data.accessToken,
refreshToken: data.refreshToken,
memberID: await fetchMemberId(),
loginType: .apple)
authManager.memberID = await fetchMemberID()
return true
} catch {
os_log(.error, log: .data, "Failed to sign up with error: %@", error.localizedDescription)
return false
}
}

private func fetchMemberId() async -> Int? {
private func fetchMemberID() async -> Int? {
let endPoint = userEndPointFactory.makeUserInformationEndPoint(with: nil)
do {
let responseData = try await provider.request(with: endPoint)
Expand Down