summaryrefslogtreecommitdiff
path: root/www/js
diff options
context:
space:
mode:
authorPliable Pixels <pliablepixels@gmail.com>2019-07-15 15:59:52 -0400
committerPliable Pixels <pliablepixels@gmail.com>2019-07-15 15:59:52 -0400
commit69208e66b4b155dec047b1837ec6ecc05e8c6dab (patch)
treef23a0f6834d39c85517b12127f62def94d05c431 /www/js
parentcdf7b2897ff2fd61e79ff53f801a0592b9627176 (diff)
#833, do a reachability before first attempt, fix return so that we don't broadcast success before auth is over
Diffstat (limited to 'www/js')
-rw-r--r--www/js/NVR.js2
-rwxr-xr-xwww/js/app.js57
2 files changed, 24 insertions, 35 deletions
diff --git a/www/js/NVR.js b/www/js/NVR.js
index 1d0737e6..1d9c6ca8 100644
--- a/www/js/NVR.js
+++ b/www/js/NVR.js
@@ -563,7 +563,7 @@ angular.module('zmApp.controllers')
//console.log("******************* API login error " + JSON.stringify(err));
$ionicLoading.hide();
//if (err && err.data && 'success' in err.data) {
- log("API based login not supported, need to use web scraping..."+JSON.stringify(err));
+ log("API based login not supported, need to use web scraping...");
// login using old web scraping
loginData.loginAPISupported = false;
diff --git a/www/js/app.js b/www/js/app.js
index 89944da6..3545cb2a 100755
--- a/www/js/app.js
+++ b/www/js/app.js
@@ -994,7 +994,7 @@ angular.module('zmApp', [
}
function _doLogoutAndLogin(str) {
- NVR.debug ("Clearing cookies");
+ NVR.debug ("_doLogoutAndLogin: Clearing cookies");
if (window.cordova) {
// we need to do this or ZM will send same auth hash
@@ -1007,11 +1007,22 @@ angular.module('zmApp', [
$cookies.remove(k);
});
}*/
- return NVR.logout()
+ return NVR.getReachableConfig(false)
+ .then (
+ function(data ) {
+ return NVR.logout()
.then(function (ans) {
return _doLogin(str);
});
+ },
+ function (err) {
+ NVR.log('No reachable config: '+JSON.stringify(err));
+ $state.go("app.invalidapi");
+ return;
+ }
+ );
+
}
@@ -1019,16 +1030,17 @@ angular.module('zmApp', [
var d = $q.defer();
var ld = NVR.getLogin();
- var statename = $ionicHistory.currentStateName();
-
+ //var statename = $ionicHistory.currentStateName();
+ NVR.debug ("Inside _doLogin()");
+/*
if (statename == "montage-history") {
NVR.log("Skipping login process as we are in montage history. Re-logging will mess up the stream");
d.resolve("success");
return d.promise;
}
-
+*/
NVR.isReCaptcha()
.then(function (result) {
if (result == true) {
@@ -1069,35 +1081,10 @@ angular.module('zmApp', [
return d.promise;
},
function (error)
- // login to main failed, so try others
{
- $ionicLoading.show({
- template: $translate.instant('kReachabilityFailed'),
- noBackdrop: true,
-
- });
- NVR.debug(">>>>>>>>>>>> Failed first login, trying reachability");
- NVR.getReachableConfig(true)
- .then(function (data) {
- NVR.proceedWithLogin()
- .then(function (success) {
- d.resolve(success);
- $ionicLoading.hide();
- return d.promise;
- },
- function (error) {
- $ionicLoading.hide();
- d.reject(error);
- return d.promise;
- });
-
- },
- function (error) {
- $ionicLoading.hide();
- d.reject(error);
- return d.promise;
- });
-
+ $ionicLoading.hide();
+ d.reject(error);
+ return d.promise;
});
return d.promise;
@@ -2118,6 +2105,8 @@ angular.module('zmApp', [
if (arguments[0].timeout) options.timeout = arguments[0].timeout;
// console.log ("**** -->"+method+"<-- using native HTTP with:"+encodeURI(url)+" payload:"+JSON.stringify(options));
+
+
cordova.plugin.http.sendRequest(encodeURI(url), options,
function (succ) {
// automatic JSON parse if no responseType: text
@@ -2159,7 +2148,7 @@ angular.module('zmApp', [
},
function (err) {
- nvr.debug("*** Inside native HTTP error");
+ nvr.debug("*** Inside native HTTP error for url:"+err.url);
if (err.status == 401 && !options.skipIntercept && nvr.apiValid) {
if (err.error && err.error.indexOf("API is disabled for user") != -1) {
nvr.apiValid = false;