Skip to content
This repository has been archived by the owner on Jan 6, 2024. It is now read-only.

Commit

Permalink
refactor: 로그인 실패 시 message 변경 #82
Browse files Browse the repository at this point in the history
- 중복 호출 방지 throttle 방식 사용하여 개선
  • Loading branch information
llghdud921 committed Jul 25, 2022
1 parent 348713e commit f9adff5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
7 changes: 5 additions & 2 deletions Weekand/Weekand/Networking/Error/SignInError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@
import Foundation

enum SignInError {
case noExistUser
case notFoundUser
case notMatchIdPassword

var serverDescription: String {
switch self {
case .noExistUser:
case .notFoundUser:
return "존재하지 않는 유저입니다."
case .notMatchIdPassword:
return "이메일, 비밀번호가 일치하지 않습니다."
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ extension PasswordFindViewModel {
informText: "임시비밀번호가 발급되었습니다.",
dismissParentCoordinator: true)
}, onFailure: { error in
if error.localizedDescription == SignInError.noExistUser.serverDescription {
if error.localizedDescription == SignInError.notFoundUser.serverDescription {
self.coordinator?.showToastMessage(text: "가입되지 않은 이메일입니다")
} else {
self.coordinator?.showToastMessage(text: "네트워크 요청에 실패하였습니다")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class SignInViewModel: ViewModelType {

input.nextButtonDidTapEvent
.withLatestFrom(isCheckEmailPassword)
.distinctUntilChanged { $0 == $1 }
.throttle(.seconds(4), latest: false, scheduler: MainScheduler.instance)
.subscribe(onNext: { [weak self] email, password in
self?.login(email: email, password: password)
}).disposed(by: disposeBag)
Expand All @@ -83,8 +83,12 @@ extension SignInViewModel {
self.signInUseCase.login(email: emailText, password: passwordText).subscribe(onSuccess: { tokenData in
ToeknManager.shared.createTokens(accessToken: tokenData.accessToken, refreshToken: tokenData.refreshToken)
self.userID()
}, onFailure: { _ in
self.coordinator?.showToastMessage(text: "네트워크 요청에 실패하였습니다")
}, onFailure: { error in
if error.localizedDescription == SignInError.notMatchIdPassword.serverDescription {
self.coordinator?.showToastMessage(text: "이메일·비밀번호가 일치하지 않습니다.")
} else {
self.coordinator?.showToastMessage(text: "네트워크 요청에 실패하였습니다")
}
}, onDisposed: nil)
.disposed(by: disposeBag)
}
Expand Down

0 comments on commit f9adff5

Please sign in to comment.