diff --git a/AgileWorks/AgileWorks/Login/View/LoginViewController.swift b/AgileWorks/AgileWorks/Login/View/LoginViewController.swift index b475d2baae924625af013508963ab0deae5442d1..326bd0052a445c3e21c099bd5e482acf782fa138 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 6141dc13517e9211cb2cfaab114964e53293f079..078679976a433beb5f2236aeed921a077964376e 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 == OIDErrorCode.userCanceledAuthorizationFlow.rawValue { + completion(.failure(.loginCancel)) + } else { + completion(.failure(.oauthError)) + } + } else { + completion(.failure(.oauthError)) + } } } }