diff --git a/GMERemittance/Module/Home/Application Logic/Interactor/HomeInteractor.swift b/GMERemittance/Module/Home/Application Logic/Interactor/HomeInteractor.swift index 365b829e..e56b24ad 100644 --- a/GMERemittance/Module/Home/Application Logic/Interactor/HomeInteractor.swift +++ b/GMERemittance/Module/Home/Application Logic/Interactor/HomeInteractor.swift @@ -34,6 +34,12 @@ extension HomeInteractor: HomeInteractorInput { self.output?.show(model: user) }) { error in + if let _error = error as? NSError { + if _error.code == AppConstants.emergencyLogoutErrorCode { + self.output?.show(panicError: error) + } + return + } self.output?.show(error: error) } } diff --git a/GMERemittance/Module/Home/Application Logic/Interactor/HomeInteractorIO.swift b/GMERemittance/Module/Home/Application Logic/Interactor/HomeInteractorIO.swift index b5f5e73b..e022ef01 100644 --- a/GMERemittance/Module/Home/Application Logic/Interactor/HomeInteractorIO.swift +++ b/GMERemittance/Module/Home/Application Logic/Interactor/HomeInteractorIO.swift @@ -13,4 +13,5 @@ protocol HomeInteractorInput: class { protocol HomeInteractorOutput: class { func show(model: User) func show(error: Error) + func show(panicError: Error) } diff --git a/GMERemittance/Module/Home/Application Logic/Service/HomeServiceType.swift b/GMERemittance/Module/Home/Application Logic/Service/HomeServiceType.swift index 1f6d2c57..e8d24b2d 100644 --- a/GMERemittance/Module/Home/Application Logic/Service/HomeServiceType.swift +++ b/GMERemittance/Module/Home/Application Logic/Service/HomeServiceType.swift @@ -8,6 +8,8 @@ import Foundation + + protocol HomeServiceType: class, UserInfoService { } @@ -22,7 +24,7 @@ extension UserInfoService { let url = baseUrl + "mobile/CustomerProfile" auth.request(method: .post, url: url, params: param, success: { (response: UserContainer ) in if (response.errorCode ?? "") == "1" { - let error = NSError.init(domain: "Network", code: 0, userInfo: [NSLocalizedDescriptionKey : response.message ?? ""]) + let error = NSError.init(domain: "Network", code: AppConstants.emergencyLogoutErrorCode, userInfo: [NSLocalizedDescriptionKey : response.message ?? ""]) failure(error) }else { if let model = response.data { diff --git a/GMERemittance/Module/Home/Module Interface/HomeModuleInterface.swift b/GMERemittance/Module/Home/Module Interface/HomeModuleInterface.swift index ee0b6831..238d1671 100644 --- a/GMERemittance/Module/Home/Module Interface/HomeModuleInterface.swift +++ b/GMERemittance/Module/Home/Module Interface/HomeModuleInterface.swift @@ -13,4 +13,5 @@ protocol HomeModuleInterface: class { func openTrackYourTransfer() func showKyc() func refreshData() + func logout() } diff --git a/GMERemittance/Module/Home/User Interface/Presenter/HomePresenter.swift b/GMERemittance/Module/Home/User Interface/Presenter/HomePresenter.swift index c400d73f..284aefdd 100644 --- a/GMERemittance/Module/Home/User Interface/Presenter/HomePresenter.swift +++ b/GMERemittance/Module/Home/User Interface/Presenter/HomePresenter.swift @@ -45,6 +45,10 @@ extension HomePresenter: HomeModuleInterface { func refreshData() { self.interactor?.fetchUserInfo() } + + func logout() { + wireframe?.logOut() + } } // MARK: Home interactor output interface @@ -59,4 +63,8 @@ extension HomePresenter: HomeInteractorOutput { self.view?.endRefreshing() self.view?.show(error: error.localizedDescription) } + + func show(panicError: Error) { + self.view?.show(panicError: panicError.localizedDescription) + } } diff --git a/GMERemittance/Module/Home/User Interface/View/HomeViewController.swift b/GMERemittance/Module/Home/User Interface/View/HomeViewController.swift index 213b6727..310543ff 100644 --- a/GMERemittance/Module/Home/User Interface/View/HomeViewController.swift +++ b/GMERemittance/Module/Home/User Interface/View/HomeViewController.swift @@ -360,6 +360,12 @@ extension HomeViewController: HomeViewInterface { self.alert(message: error) } + func show(panicError: String) { + self.alert(message: panicError, title: "Warning") { + self.presenter?.logout() + } + } + func showLoading() { self.showProgressHud() } diff --git a/GMERemittance/Module/Home/User Interface/View/HomeViewInterface.swift b/GMERemittance/Module/Home/User Interface/View/HomeViewInterface.swift index 73f3735f..5ac75b70 100644 --- a/GMERemittance/Module/Home/User Interface/View/HomeViewInterface.swift +++ b/GMERemittance/Module/Home/User Interface/View/HomeViewInterface.swift @@ -12,4 +12,5 @@ protocol HomeViewInterface: class { func showLoading() func hideLoading() func endRefreshing() + func show(panicError: String) } diff --git a/GMERemittance/Module/Home/User Interface/Wireframe/HomeWireframe.swift b/GMERemittance/Module/Home/User Interface/Wireframe/HomeWireframe.swift index 4031eb3d..9b4022fc 100644 --- a/GMERemittance/Module/Home/User Interface/Wireframe/HomeWireframe.swift +++ b/GMERemittance/Module/Home/User Interface/Wireframe/HomeWireframe.swift @@ -66,4 +66,8 @@ extension HomeWireframe: HomeWireframeInput { self.kycWireFrame.pushMainView(in: navigation) } } + + func logOut() { + MainWireframe.logout() + } } diff --git a/GMERemittance/Module/Home/User Interface/Wireframe/HomeWireframeInput.swift b/GMERemittance/Module/Home/User Interface/Wireframe/HomeWireframeInput.swift index 8e5d1b0f..ec22d610 100644 --- a/GMERemittance/Module/Home/User Interface/Wireframe/HomeWireframeInput.swift +++ b/GMERemittance/Module/Home/User Interface/Wireframe/HomeWireframeInput.swift @@ -14,4 +14,5 @@ protocol HomeWireframeInput: WireframeInput { func openSendMoney() func openTrackYourTransfer() func openKyc() + func logOut() } diff --git a/GMERemittance/Utility/AppConstants.swift b/GMERemittance/Utility/AppConstants.swift index 4925a02e..8388a62d 100644 --- a/GMERemittance/Utility/AppConstants.swift +++ b/GMERemittance/Utility/AppConstants.swift @@ -17,6 +17,7 @@ class AppConstants { static let themeRedColor = UIColor.init(hex: "#da3832") static let themeBlueColor = UIColor.init(hex: "#010538") static let themWhiteColor = UIColor.init(hex: "#ffffff") + static let emergencyLogoutErrorCode = -1111 } enum Devices {