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 /www/js/NVR.js | |
| parent | 2e44ed65be3ad42190af1e590a30ac2866ef65c4 (diff) | |
handle case when auth is specified but it is actually off
Diffstat (limited to 'www/js/NVR.js')
| -rw-r--r-- | www/js/NVR.js | 50 |
1 files changed, 34 insertions, 16 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; } |
