From: surya.kumar7 Date: Mon, 8 Apr 2019 15:24:55 +0000 (+0530) Subject: Handle Authentication Challenge X-Git-Tag: submit/tizen/20190412.025133~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=aee9eee58de097fecd83c1a86f7308bb46249d55;p=platform%2Fframework%2Fweb%2Fwrtjs.git Handle Authentication Challenge Added support to gather and submit login info if server is requesting for authentication for Tizen web apps Depends on: https://review.tizen.org/gerrit/203000 Change-Id: I17ea4fefb7ece078bef1d6cf2499078e36122f79 Signed-off-by: surya.kumar7 --- diff --git a/wrt_app/src/web_application.js b/wrt_app/src/web_application.js index ae0cfc3a..789d2d06 100755 --- a/wrt_app/src/web_application.js +++ b/wrt_app/src/web_application.js @@ -100,6 +100,18 @@ class WebApplication { self.pendingCallbacks.delete(id); } }); + wrt.on('auth-response', function(event, id, submit, user, passwd) { + let callback = self.pendingCallbacks.get(id); + if (typeof callback === 'function') { + console.log('calling auth response callback'); + if (submit) { + callback(user, passwd); + } else { + callback(); + } + self.pendingCallbacks.delete(id); + } + }); app.on('certificate-error', function(event, webContents, url, error, certificate, callback) { console.log('A certificate error has occurred'); event.preventDefault(); @@ -132,6 +144,14 @@ class WebApplication { const ses = webContents.session; ses.setPermissionRequestHandler(handlePermissionRequests); }); + app.on('login', function(event, webContents, request, authInfo, callback) { + console.log('Login info is required'); + event.preventDefault(); + const id = ++self.pendingID; + console.log(`Raising a login info request with id: ${id}`); + self.pendingCallbacks.set(id, callback); + wrt.handleAuthRequest(id, webContents); + }); } suspend() { console.log('WebApplication : suspend');