From d8fea09d65e5207ef8c4fafcddd5fc74a7f7be00 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Fri, 28 Sep 2018 08:37:24 -0400 Subject: #709 implement native/XHR wrapper, convert all success/error to "then" construct --- www/js/MenuController.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'www/js/MenuController.js') diff --git a/www/js/MenuController.js b/www/js/MenuController.js index 995abba3..8de4aeb3 100644 --- a/www/js/MenuController.js +++ b/www/js/MenuController.js @@ -119,8 +119,9 @@ angular.module('zmApp.controllers').controller('MenuController', ['$scope', '$io NVRDataModel.log("Validating APIs at " + apiurl); $http.get(apiurl) - .success(function (data) { + .then(function (data) { + data = data.data; NVRDataModel.getTimeZone(true); var loginStatus = $translate.instant('kExploreEnjoy') + " " + $rootScope.appName + "!"; EventServer.refresh(); @@ -135,7 +136,8 @@ angular.module('zmApp.controllers').controller('MenuController', ['$scope', '$io NVRDataModel.log("ZM relative cgi-path: " + zm_cgi + ", you entered: " + user_cgi); $http.get(ld.streamingurl + "/zms") - .success(function (data) { + .then(function (data) { + data = data.data; NVRDataModel.debug("Urk! cgi-path returned success, but it should not have come here"); loginStatus = $translate.instant('kLoginStatusNoCgi'); @@ -183,8 +185,8 @@ angular.module('zmApp.controllers').controller('MenuController', ['$scope', '$io }); - }) - .error(function (error, status) { + }, + function (error, status) { // If its 5xx, then the cgi-bin path is valid // if its 4xx then the cgi-bin path is not valid @@ -233,8 +235,8 @@ angular.module('zmApp.controllers').controller('MenuController', ['$scope', '$io }); }); - }) - .error(function (error) { + }, + function (error) { NVRDataModel.displayBanner('error', [$translate.instant('kBannerAPICheckFailed'), $translate.instant('kBannerPleaseCheck')]); NVRDataModel.log("API login error " + JSON.stringify(error)); -- cgit v1.2.3 From ebe04f8fc791413131c37425998be5be4a2ef538 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Fri, 28 Sep 2018 14:29:43 -0400 Subject: #709 dont escape urls in caller, incorporate cordova http ssl and basic auth checks --- www/js/MenuController.js | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'www/js/MenuController.js') diff --git a/www/js/MenuController.js b/www/js/MenuController.js index 8de4aeb3..1ab7a6fa 100644 --- a/www/js/MenuController.js +++ b/www/js/MenuController.js @@ -2,14 +2,14 @@ /* jslint browser: true*/ /* global cordova,StatusBar,angular,console */ -angular.module('zmApp.controllers').controller('MenuController', ['$scope', '$ionicSideMenuDelegate', 'zm', '$stateParams', '$ionicHistory', '$state', 'NVRDataModel', '$rootScope', '$ionicPopup', '$translate', '$timeout', '$location','EventServer', 'zmAutoLogin','$http',function ($scope, $ionicSideMenuDelegate, zm, $stateParams, $ionicHistory, $state, NVRDataModel, $rootScope, $ionicPopup, $translate, $timeout, $location, EventServer, zmAutoLogin, $http) { +angular.module('zmApp.controllers').controller('MenuController', ['$scope', '$ionicSideMenuDelegate', 'zm', '$stateParams', '$ionicHistory', '$state', 'NVRDataModel', '$rootScope', '$ionicPopup', '$translate', '$timeout', '$location','EventServer', 'zmAutoLogin','$http','SecuredPopups',function ($scope, $ionicSideMenuDelegate, zm, $stateParams, $ionicHistory, $state, NVRDataModel, $rootScope, $ionicPopup, $translate, $timeout, $location, EventServer, zmAutoLogin, $http, SecuredPopups) { $scope.openMenu = function () { $ionicSideMenuDelegate.toggleLeft(); }; //---------------------------------------------------------------- // This controller sits along with the main app to bring up - // the language menu from the main menu + // the language menu from the main //---------------------------------------------------------------- @@ -83,6 +83,33 @@ angular.module('zmApp.controllers').controller('MenuController', ['$scope', '$io } + + if (window.cordova) { + + if (loginData.isUseBasicAuth) { + NVRDataModel.debug ("Cordova HTTP: configuring basic auth"); + cordova.plugin.http.useBasicAuth(loginData.basicAuthUser, loginData.basicAuthPassword); + } + + if (loginData.enableStrictSSL) { + + //alert("Enabling insecure SSL"); + NVRDataModel.log(">>>> Disabling strict SSL checking (turn off in Dev Options if you can't connect)"); + cordova.plugin.http.setSSLCertMode('nocheck', function() { + NVRDataModel.debug('--> SSL is permissive, will allow any certs. Use at your own risk.'); + }, function() { + console.log('-->Error setting SSL permissive'); + }); + + } else { + + NVRDataModel.log(">>>> Enabling strict SSL checking (turn off in Dev Options if you can't connect)"); + + } + + } + + if (loginData.isUseEventServer) { EventServer.init(); if ($rootScope.apnsToken && loginData.disablePush != true) { -- cgit v1.2.3 From 736002099098b9e044000dd02f359182c4043ef8 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Sat, 29 Sep 2018 16:47:06 -0400 Subject: certificate fixes --- www/js/MenuController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'www/js/MenuController.js') diff --git a/www/js/MenuController.js b/www/js/MenuController.js index 1ab7a6fa..52ab51ac 100644 --- a/www/js/MenuController.js +++ b/www/js/MenuController.js @@ -91,7 +91,7 @@ angular.module('zmApp.controllers').controller('MenuController', ['$scope', '$io cordova.plugin.http.useBasicAuth(loginData.basicAuthUser, loginData.basicAuthPassword); } - if (loginData.enableStrictSSL) { + if (!loginData.enableStrictSSL) { //alert("Enabling insecure SSL"); NVRDataModel.log(">>>> Disabling strict SSL checking (turn off in Dev Options if you can't connect)"); -- cgit v1.2.3 From bace2be553e3175ba7a47024c8352e43d285b620 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Mon, 8 Oct 2018 12:14:32 -0400 Subject: log cleanup, wait for eventserver init before sending messages --- www/js/MenuController.js | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'www/js/MenuController.js') diff --git a/www/js/MenuController.js b/www/js/MenuController.js index 52ab51ac..d9d4d114 100644 --- a/www/js/MenuController.js +++ b/www/js/MenuController.js @@ -111,21 +111,20 @@ angular.module('zmApp.controllers').controller('MenuController', ['$scope', '$io if (loginData.isUseEventServer) { - EventServer.init(); - if ($rootScope.apnsToken && loginData.disablePush != true) { - NVRDataModel.log("Making sure we get push notifications"); - EventServer.sendMessage('push', { - type: 'token', - platform: $rootScope.platformOS, - token: $rootScope.apnsToken, - state: "enabled" - }, 1); - } - EventServer.sendMessage("control", { - type: 'filter', - monlist: loginData.eventServerMonitors, - intlist: loginData.eventServerInterval + EventServer.init() + .then (function (succ) { + EventServer.sendMessage("control", { + type: 'filter', + monlist: loginData.eventServerMonitors, + intlist: loginData.eventServerInterval, + token: $rootScope.apnsToken + }); + }, + function (err) { + NVRDataModel.debug ("EventServer init failed"); }); + + } -- cgit v1.2.3