From e3748e7bef669f609e3e05a410d0e2ade4a23d71 Mon Sep 17 00:00:00 2001 From: Max Laverse Date: Tue, 9 Apr 2019 14:25:55 +0200 Subject: [PATCH] Support redirection to success.shtml --- KeepMeConnected/Info.plist | 2 +- KeepMeConnected/WatchGuard.swift | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/KeepMeConnected/Info.plist b/KeepMeConnected/Info.plist index 8a99d99..af2e8ee 100644 --- a/KeepMeConnected/Info.plist +++ b/KeepMeConnected/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.0.0 + 1.0.1 CFBundleVersion 1 LSApplicationCategoryType diff --git a/KeepMeConnected/WatchGuard.swift b/KeepMeConnected/WatchGuard.swift index 8131825..6be2ddb 100644 --- a/KeepMeConnected/WatchGuard.swift +++ b/KeepMeConnected/WatchGuard.swift @@ -73,12 +73,14 @@ class WatchGuard: NSObject { handler(WatchGuardLoginResponse.Error(error!.localizedDescription.dropSuffix("."))) } else { if let httpResponse = response as? HTTPURLResponse { - if httpResponse.url == portalUrl{ + if httpResponse.url == portalUrl || httpResponse.url?.absoluteString.range(of:"success.shtml") != nil { handler(WatchGuardLoginResponse.Success) }else{ if let errcode = URLComponents(string: httpResponse.url!.absoluteString)?.queryItems?.filter({$0.name == "errcode"}).first?.value { + os_log("Error on logon. Error (%@) '%@'",errcode,WatchGuard.getErrorCodeStr(errcode)) handler(WatchGuardLoginResponse.Failed(WatchGuard.getErrorCodeStr(errcode))) }else{ + os_log("Error on logon. Wrong base '%@'",httpResponse.url!.absoluteString) handler(WatchGuardLoginResponse.Error(String(format: "Missing errcode in redirection to '%@'",httpResponse.url!.absoluteString))) } } @@ -121,6 +123,7 @@ class WatchGuard: NSObject { handler(WatchGuardLogoutResponse.Error(WatchGuard.getErrorCodeStr(errcode))) } }else{ + os_log("Error on logout. Missing errcode in '%@'",httpResponse.url!.absoluteString) let dataString = String(NSString(data: data!, encoding: String.Encoding.utf8.rawValue)!) handler(WatchGuardLogoutResponse.Error(String(format: "Missing errcode '%@': %@",httpResponse.url!.absoluteString, dataString))) }