Skip to content

Commit

Permalink
added a bit more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
twocanoes committed Sep 30, 2022
1 parent 5f38e70 commit e2d2330
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions XCreds/WebView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ extension WebViewController: WKNavigationDelegate {
let javaScript = "document.getElementById('\(passwordElementID.sanitized())').value"
webView.evaluateJavaScript(javaScript, completionHandler: { response, error in
if let rawPass = response as? String, rawPass != "" {
TCSLogWithMark("password set.")
TCSLogWithMark("========= password set===========")
self.password=rawPass
}
else {
TCSLogWithMark("No password found")
TCSLogWithMark("password not captured")
return
}
})
Expand All @@ -108,10 +108,12 @@ extension WebViewController: WKNavigationDelegate {
///passwordInput
webView.evaluateJavaScript(javaScript, completionHandler: { response, error in
if let rawPass = response as? String {
TCSLogWithMark("========= password set===========")

self.password=rawPass
}
else {
TCSLogWithMark("No password found")
TCSLogWithMark("password not captured")

}
})
Expand All @@ -128,10 +130,12 @@ extension WebViewController: WKNavigationDelegate {
let javaScript = "document.querySelector('input[type=password]').value"
webView.evaluateJavaScript(javaScript, completionHandler: { response, error in
if let rawPass = response as? String {
TCSLogWithMark("========= password set===========")

self.password=rawPass
}
else {
TCSLogWithMark("No password found")
TCSLogWithMark("password not captured")
}
})
} else if navigationAction.request.url?.path.contains("verify") ?? false {
Expand All @@ -151,7 +155,7 @@ extension WebViewController: WKNavigationDelegate {
}
webView.evaluateJavaScript(javaScript, completionHandler: { response, error in
if let rawPass = response as? String, rawPass != "" {
TCSLogWithMark("password set.")
TCSLogWithMark("========= password set===========")
self.password=rawPass
}
})
Expand Down Expand Up @@ -229,21 +233,18 @@ extension WebViewController: OIDCLiteDelegate {
}

func tokenResponse(tokens: OIDCLiteTokenResponse) {
TCSLogWithMark("tokenResponse")
TCSLogWithMark("======== tokenResponse =========")
RunLoop.main.perform {
if let password = self.password {
TCSLogWithMark("password received")
TCSLogWithMark("----- Password was set")
let returnTokens = Tokens(password: password, accessToken: tokens.accessToken ?? "", idToken: tokens.idToken ?? "", refreshToken: tokens.refreshToken ?? "")
self.tokensUpdated(tokens: returnTokens)
NotificationCenter.default.post(name: Notification.Name("TCSTokensUpdated"), object: self, userInfo:["tokens":returnTokens]

)

}
else {
TCSLogWithMark("no password!")
TCSLogWithMark("----- password was not set")
NotificationCenter.default.post(name: Notification.Name("TCSTokensUpdated"), object: self, userInfo:[:])

}
}
}
Expand Down
Binary file not shown.

0 comments on commit e2d2330

Please sign in to comment.