diff options
| author | Pliable Pixels <pliablepixels@gmail.com> | 2019-05-31 13:18:25 -0400 |
|---|---|---|
| committer | Pliable Pixels <pliablepixels@gmail.com> | 2019-05-31 13:18:25 -0400 |
| commit | db03aaedefed847d7026b0964a487e3ee26f1bc1 (patch) | |
| tree | da0418ed3a41c5ac27c8b5b252d821263ce725ec | |
| parent | 2e44ed65be3ad42190af1e590a30ac2866ef65c4 (diff) | |
handle case when auth is specified but it is actually off
| -rw-r--r-- | www/js/NVR.js | 50 | ||||
| -rw-r--r-- | www/js/WizardCtrl.js | 3 |
2 files changed, 36 insertions, 17 deletions
diff --git a/www/js/NVR.js b/www/js/NVR.js index 4eb81534..8166a1de 100644 --- a/www/js/NVR.js +++ b/www/js/NVR.js @@ -483,15 +483,24 @@ angular.module('zmApp.controllers') } else { - if (succ.credentials) { - log ("Could not recover token details, trying old auth credentials"); - loginData.isTokenSupported = false; - setLogin(loginData); - $rootScope.authSession = "&" + succ.credentials; - if (succ.append_password == '1') { - $rootScope.authSession = $rootScope.authSession + - loginData.password; + if (succ.credentials != undefined) { + if (succ.credentials != '') { + log ("Could not recover token details, trying old auth credentials"); + loginData.isTokenSupported = false; + setLogin(loginData); + $rootScope.authSession = "&" + succ.credentials; + if (succ.append_password == '1') { + $rootScope.authSession = $rootScope.authSession + + loginData.password; + } + } else { + // incase auth is turned off, but user said + // its on. + $rootScope.authSession="&nonauth=none"; + debug ('Your auth seems to be turned off, but you said yes'); + } + } else { log ("Neither token nor old cred worked. Seems like an error"); @@ -706,24 +715,33 @@ angular.module('zmApp.controllers') if (loginData.currentServerVersion && (versionCompare(loginData.currentServerVersion, zm.versionWithLoginAPI) != -1 || loginData.loginAPISupported)) { - myurl = loginData.apiurl + '/host/getCredentials.json'; - debug("Server version " + loginData.currentServerVersion + " > 1.31.41, so using getCredentials API:" + myurl); + myurl = loginData.apiurl + '/host/login.json'; + debug("Server version " + loginData.currentServerVersion + " > 1.31.41, so using login API:" + myurl); $http.get(myurl) .then(function (s) { debug("Credentials API returned: " + JSON.stringify(s)); - if (!s.data || !s.data.credentials) { + if (!s.data || s.data.credentials == undefined) { $rootScope.authSession = ""; d.resolve($rootScope.authSession); - debug("getCredentials() API Succeded, but did NOT return credentials key: " + JSON.stringify(s)); + debug("login() API Succeded, but did NOT return credentials key: " + JSON.stringify(s)); return d.promise; } else { - $rootScope.authSession = "&" + s.data.credentials; - if (s.data.append_password == '1') { - $rootScope.authSession = $rootScope.authSession + - loginData.password; + if (s.data.credentials != '') { + $rootScope.authSession = "&" + s.data.credentials; + if (s.data.append_password == '1') { + $rootScope.authSession = $rootScope.authSession + + loginData.password; + } } + else { + // incase auth is turned off, but user said + // its on. + $rootScope.authSession="&nonauth=none"; + debug ('Your auth seems to be turned off, but you said yes'); + } + d.resolve($rootScope.authSession); return d.promise; } diff --git a/www/js/WizardCtrl.js b/www/js/WizardCtrl.js index 86c4cbe9..726cc6f4 100644 --- a/www/js/WizardCtrl.js +++ b/www/js/WizardCtrl.js @@ -131,8 +131,9 @@ angular.module('zmApp.controllers').controller('zmApp.WizardCtrl', ['$scope', '$ if (tail) t = tail; //$ionicLoading.show({template: 'trying ' + urls[0].server}); NVR.log("zmWizard test.." + urls[0] + t); - return $http.get(urls[0] + t).then(function () { + return $http.get(urls[0] + t).then(function (succ) { NVR.log("Success: on " + urls[0] + t); + //NVR.log (JSON.stringify(succ)); //$ionicLoading.hide(); d.resolve(urls[0]); return d.promise; |
