[VD] When login in proxy server, check usrname/passwd from vconf 22/217422/10
authorliwei <wei90727.li@samsung.com>
Mon, 11 Nov 2019 10:24:41 +0000 (18:24 +0800)
committerliwei <wei90727.li@samsung.com>
Tue, 19 Nov 2019 07:30:44 +0000 (15:30 +0800)
For TV product, when login in proxy server, get usrname/passwd from
vconf(memory/dnet/proxy), if usrname/passwd exist, login proxy server
automatically, popup will not be shown anymore.
Vconf format: http://ubuntu:123456@109.123.100.175:8899

Native Patch:
https://review.tizen.org/gerrit/217425

Change-Id: I042f9f2f8fbe678065a6b76a9e943dfbf7b4db62
Signed-off-by: liwei <wei90727.li@samsung.com>
wrt_app/src/web_application.js [changed mode: 0755->0644]

old mode 100755 (executable)
new mode 100644 (file)
index 3afba33..5c848b3
@@ -117,12 +117,26 @@ class WebApplication {
             }
         });
         app.on('login', function(event, webContents, request, authInfo, callback) {
-            console.log('Login info is required');
+            console.log(`Login info is required, isproxy: ${authInfo.isProxy}`);
             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);
+            let usrname = '';
+            let passwd = '';
+            if (self.isTVProfile && authInfo.isProxy) {
+                let vconfProxy = wrt.getProxy();
+                if (vconfProxy) {
+                    let proxyInfo = new URL(vconfProxy);
+                    usrname = proxyInfo.username;
+                    passwd = proxyInfo.password;
+                }
+            }
+            if (usrname && passwd) {
+                callback(usrname, passwd);
+            } else {
+                const id = ++self.pendingID;
+                console.log(`Raising a login info request with id: ${id}`);
+                self.pendingCallbacks.set(id, callback);
+                wrt.handleAuthRequest(id, webContents);
+            }
         });
         if (this.isTVProfile) {
             // TODO. This logic in only for QA verification
@@ -141,25 +155,28 @@ class WebApplication {
             });
         }
         if (this.accessiblePath) {
-            console.log('accessiblePath : ' + this.accessiblePath);
+            console.log(`accessiblePath: ${this.accessiblePath}`);
             protocol.interceptFileProtocol('file', (request, callback) => {
-                const url = require('url');
-                let access_path, parsed_info = url.parse(request.url);
-                access_path = parsed_info.host + parsed_info.pathname;
-                console.log("check path: " + access_path);
-
-                for (let p in self.accessiblePath) {
-                    if (access_path.startsWith(self.accessiblePath[p])) {
+                if (request.url) {
+                    let access_path, parsed_info = new URL(request.url);
+                    access_path = parsed_info.host + parsed_info.pathname;
+                    console.log(`check path: : ${access_path}`);
+                    for (let p in self.accessiblePath) {
+                        if (access_path.startsWith(self.accessiblePath[p])) {
+                            callback(access_path);
+                            return;
+                        }
+                    }
+                    if (access_path.indexOf("/shared/res/") > -1) {
                         callback(access_path);
                         return;
                     }
-                }
-                if (access_path.indexOf("/shared/res/") > -1) {
-                    callback(access_path);
-                    return;
-                }
-                else {
-                    console.log("invalid access: " + access_path);
+                    else {
+                        console.log(`invalid accesspath: ${access_path}`);
+                        callback(403);
+                    }
+                } else {
+                    console.log('request url is empty');
                     callback(403);
                 }
             }, (error) => {