Skip to content

Commit 177741a

Browse files
committed
Updates for WKWebView edit
1 parent 0722b80 commit 177741a

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

tns-oauth-webview-helper.ios.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ export class TnsOAuthWebViewHelper extends NSObject implements WKNavigationDeleg
4545

4646

4747
public webViewDecidePolicyForNavigationActionDecisionHandler(webView, navigationAction, decisionHandler) {
48+
//decisionHandler(WKNavigationActionPolicy.Allow);
49+
this._checkCodeIntercept(webView, null);
4850
this._origDelegate.webViewDecidePolicyForNavigationActionDecisionHandler(webView, navigationAction, decisionHandler);
4951
}
5052

tns-oauth.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ export function loginViaAuthorizationCodeFlow(credentials: TnsOAuthModule.ITnsOA
105105
return new Promise((resolve, reject) => {
106106
var navCount = 0;
107107

108+
let hasCode = false;
109+
108110
let checkCodeIntercept = (webView, error, url): boolean => {
109111
var retStr = '';
110112
try {
@@ -134,7 +136,8 @@ export function loginViaAuthorizationCodeFlow(credentials: TnsOAuthModule.ITnsOA
134136
let qsObj = querystring.parse(parsedRetStr.query);
135137
let codeStr = qsObj['code'] ? qsObj['code'] : qsObj['xsrfsign'];
136138
let errSubCode = qsObj['error_subcode'];
137-
if (codeStr) {
139+
if (codeStr && !hasCode) {
140+
hasCode = true;
138141
try {
139142
getTokenFromCode(credentials, codeStr)
140143
.then((response: TnsOAuthModule.ITnsOAuthTokenResult) => {

0 commit comments

Comments
 (0)