diff --git a/Weekand/Weekand/Networking/Error/SignInError.swift b/Weekand/Weekand/Networking/Error/SignInError.swift new file mode 100644 index 00000000..e3c1c476 --- /dev/null +++ b/Weekand/Weekand/Networking/Error/SignInError.swift @@ -0,0 +1,19 @@ +// +// SignInError.swift +// Weekand +// +// Created by 이호영 on 2022/07/26. +// + +import Foundation + +enum SignInError { + case noExistUser + + var serverDescription: String { + switch self { + case .noExistUser: + return "존재하지 않는 유저입니다." + } + } +} diff --git a/Weekand/Weekand/Presentation/SignScene/SignIn/ViewModel/PasswordFindViewModel.swift b/Weekand/Weekand/Presentation/SignScene/SignIn/ViewModel/PasswordFindViewModel.swift index ceb4e24f..aaee73e8 100644 --- a/Weekand/Weekand/Presentation/SignScene/SignIn/ViewModel/PasswordFindViewModel.swift +++ b/Weekand/Weekand/Presentation/SignScene/SignIn/ViewModel/PasswordFindViewModel.swift @@ -33,7 +33,7 @@ class PasswordFindViewModel: ViewModelType { input.confirmButtonDidTapEvent .withLatestFrom(input.emailTextFieldDidEditEvent) - .distinctUntilChanged { $0 == $1 } + .throttle(.seconds(4), latest: false, scheduler: MainScheduler.instance) .map(vaildEmail) .subscribe(onNext: { email, isVaild in if isVaild { @@ -77,16 +77,16 @@ extension PasswordFindViewModel { func issueTempPassword(email: String) { self.signInUseCase.issueTempPassword(email: email) .subscribe(onSuccess: { isSucceed in - if isSucceed { - self.coordinator?.presentPopViewController( - titleText: "안내", - informText: "임시비밀번호가 발급되었습니다.", - dismissParentCoordinator: true) - } else { - self.coordinator?.showToastMessage(text: "가입되지 않은 이메일입니다") - } - }, onFailure: { _ in - self.coordinator?.showToastMessage(text: "네트워크 요청에 실패하였습니다") + self.coordinator?.presentPopViewController( + titleText: "안내", + informText: "임시비밀번호가 발급되었습니다.", + dismissParentCoordinator: true) + }, onFailure: { error in + if error.localizedDescription == SignInError.noExistUser.serverDescription { + self.coordinator?.showToastMessage(text: "가입되지 않은 이메일입니다") + } else { + self.coordinator?.showToastMessage(text: "네트워크 요청에 실패하였습니다") + } }, onDisposed: nil) .disposed(by: disposeBag) }