Skip to content

Commit

Permalink
[iOS#hotfix] 디바이스 로그인 버그 수정 (#346)
Browse files Browse the repository at this point in the history
* feat: 디바이스 Login 이슈 해결

* feat: SignOutManager 옵셔널로 수정
  • Loading branch information
leemhyungyu authored Dec 6, 2023
1 parent 422f63c commit 08b5793
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
8 changes: 4 additions & 4 deletions iOS/FlipMate/FlipMate/NetworkService/Provider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ protocol Providable {
struct Provider: Providable {
private let jsonDecoder = JSONDecoder()
private var urlSession: URLSessionable
private let signOutManager: SignOutManagerProtocol
private let signOutManager: SignOutManagerProtocol?

init(urlSession: URLSessionable, signOutManager: SignOutManagerProtocol) {
init(urlSession: URLSessionable, signOutManager: SignOutManagerProtocol? = nil) {
self.urlSession = urlSession
self.signOutManager = signOutManager
}
Expand All @@ -36,7 +36,7 @@ struct Provider: Providable {
do {
if response.statusCode == 401 {
FMLogger.general.error("토큰이 만료되어 로그인 화면으로 이동합니다.")
signOutManager.signOut()
signOutManager?.signOut()
}

let errorResult = try JSONDecoder().decode(StatusResponseWithErrorDTO.self, from: data)
Expand Down Expand Up @@ -81,7 +81,7 @@ struct Provider: Providable {
do {
if response.statusCode == 401 {
FMLogger.general.error("토큰이 만료되어 로그인 화면으로 이동합니다.")
signOutManager.signOut()
signOutManager?.signOut()
}

let errorResult = try JSONDecoder().decode(StatusResponseWithErrorDTO.self, from: data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,20 @@ final class LoginViewModel: LoginViewModelProtocol {
Task {
do {
let response = try await self.googleAuthUseCase.googleLogin(accessToken: accessToken)
isMemberSubject.send(response.isMember)


// TODO: 추후 분기 처리 (회원가입 안했을 때 고려)
let accessToken = response.accessToken
try KeychainManager.saveAccessToken(token: accessToken)
// try KeychainManager.saveAccessToken(token: accessToken)

if response.isMember {
FMLogger.user.log("나는 이미 회원이야")
try KeychainManager.saveAccessToken(token: accessToken)
} else {
FMLogger.user.log("나는 아직 회원이 아니야")
}

isMemberSubject.send(response.isMember)

} catch let error {
FMLogger.general.error("로그인 중 에러 발생 : \(error)")
}
Expand Down

0 comments on commit 08b5793

Please sign in to comment.