From e71223a7821af5590926ecf4c0f17fd0ab9b38b9 Mon Sep 17 00:00:00 2001 From: Azuma Kasumi Date: Mon, 27 Jun 2022 16:21:25 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=E3=83=AD=E3=82=B0=E3=82=A4=E3=83=B3?= =?UTF-8?q?=E3=82=AD=E3=83=A3=E3=83=B3=E3=82=BB=E3=83=AB=E6=99=82=E3=82=A8?= =?UTF-8?q?=E3=83=A9=E3=83=BC=E3=82=92=E5=87=BA=E3=81=95=E3=81=AA=E3=81=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Login/View/LoginViewController.swift | 7 ++++++- AgileWorks/Common/OAuthService.swift | 14 ++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/AgileWorks/AgileWorks/Login/View/LoginViewController.swift b/AgileWorks/AgileWorks/Login/View/LoginViewController.swift index b475d2b..326bd00 100644 --- a/AgileWorks/AgileWorks/Login/View/LoginViewController.swift +++ b/AgileWorks/AgileWorks/Login/View/LoginViewController.swift @@ -166,7 +166,12 @@ class LoginViewController: UIViewController { self.registDevice() case .failure(let error): log.e(error) - self.showLoginError(isLogout: false) + let error = error as! OAuthError + if error != .loginCancel { + self.showLoginError(isLogout: false) + } else { + self.enableLogin() + } } } } diff --git a/AgileWorks/Common/OAuthService.swift b/AgileWorks/Common/OAuthService.swift index 6141dc1..e0174e1 100644 --- a/AgileWorks/Common/OAuthService.swift +++ b/AgileWorks/Common/OAuthService.swift @@ -15,6 +15,7 @@ public enum OAuthError: Error { case oauthError case accessTokenError case sessionIdError + case loginCancel } public class OAuthService: NSObject { @@ -41,7 +42,7 @@ public class OAuthService: NSObject { responseType: OIDResponseTypeCode, additionalParameters: nil) - OAuthService.currentAuthorizationFlow = OIDAuthState.authState(byPresenting: request, presenting: viewController!) { authState, _ in + OAuthService.currentAuthorizationFlow = OIDAuthState.authState(byPresenting: request, presenting: viewController!) { authState, error in if let authState = authState { self.setAuthState(authState) log.debug(authState) @@ -59,7 +60,16 @@ public class OAuthService: NSObject { completion(.success(())) } else { self.setAuthState(nil) - completion(.failure(.oauthError)) + if let error = error as? NSError { + //ユーザーがOAuth認証コードフローを手動でキャンセル + if error.code == -3 { + completion(.failure(.loginCancel)) + } else { + completion(.failure(.oauthError)) + } + } else { + completion(.failure(.oauthError)) + } } } } -- GitLab From 643ac34279794f1d145badbd6fc1414ec3b6e1a6 Mon Sep 17 00:00:00 2001 From: Azuma Kasumi Date: Tue, 28 Jun 2022 09:24:36 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=E3=82=A8=E3=83=A9=E3=83=BC=E3=82=B3?= =?UTF-8?q?=E3=83=BC=E3=83=89=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AgileWorks/Common/OAuthService.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AgileWorks/Common/OAuthService.swift b/AgileWorks/Common/OAuthService.swift index e0174e1..0786799 100644 --- a/AgileWorks/Common/OAuthService.swift +++ b/AgileWorks/Common/OAuthService.swift @@ -62,7 +62,7 @@ public class OAuthService: NSObject { self.setAuthState(nil) if let error = error as? NSError { //ユーザーがOAuth認証コードフローを手動でキャンセル - if error.code == -3 { + if error.code == OIDErrorCode.userCanceledAuthorizationFlow.rawValue { completion(.failure(.loginCancel)) } else { completion(.failure(.oauthError)) -- GitLab