Skip to content

Commit

Permalink
Support redirection to success.shtml
Browse files Browse the repository at this point in the history
  • Loading branch information
maxlaverse committed Apr 9, 2019
1 parent 832f06c commit e3748e7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion KeepMeConnected/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<string>1.0.1</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSApplicationCategoryType</key>
Expand Down
5 changes: 4 additions & 1 deletion KeepMeConnected/WatchGuard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
}
}
Expand Down Expand Up @@ -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)))
}
Expand Down

0 comments on commit e3748e7

Please sign in to comment.