diff options
| author | Pliable Pixels <pliablepixels@gmail.com> | 2018-04-30 09:16:27 -0400 |
|---|---|---|
| committer | Pliable Pixels <pliablepixels@gmail.com> | 2018-04-30 09:16:27 -0400 |
| commit | 197cfe5807d9751ed9bb06904b1a6ff1818d25f1 (patch) | |
| tree | 3a0b91bf2895adfd5843ae8b8b8df928951b301a /www/js | |
| parent | 71ed91526ff268013295d2926b849fd71e77470d (diff) | |
update authKey to use new API
Diffstat (limited to 'www/js')
| -rwxr-xr-x | www/js/DataModel.js | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/www/js/DataModel.js b/www/js/DataModel.js index f23a17f6..e600443f 100755 --- a/www/js/DataModel.js +++ b/www/js/DataModel.js @@ -333,7 +333,51 @@ angular.module('zmApp.controllers') function getAuthKey (mid,ck) { + var d = $q.defer(); + var myurl; + + // disable for now, getAuthHash needs work + + if (versionCompare(currentServerVersion, "1.31.41") != -1 ) { + + myurl = loginData.apiurl+'/host/getAuthKey.json'; + debug ("Server version > 1.31.41, so using AuthHash API:"+myurl); + $http.get(myurl) + .then (function (s) { + + console.log ("GOT " + JSON.stringify(s)); + if (!s.data || !s.data.auth_key ) { + $rootScope.authSession = "undefined"; + d.resolve($rootScope.authSession); + debug ("AuthHash API Succeded, but did NOT return auth_key key: "+JSON.stringify(s)); + return d.promise; + + } + else { + $rootScope.authSession = "&"+s.data.auth_key; + if (s.data.append_password=='1') { + $rootScope.athSession = $rootScope.authSession + + loginData.password; + } + d.resolve($rootScope.authSession); + return d.promise; + } + + }, + function(e) { + $rootScope.authSession = "undefined"; + d.resolve($rootScope.authSession); + debug ("AuthHash API Error: "+JSON.stringify(e)); + return d.promise; + + } + ); + return d.promise; + + } + //currentServerVersion + var as = 'undefined'; if (!mid && monitors.length > 0) { @@ -349,7 +393,7 @@ angular.module('zmApp.controllers') // Skipping monitor number as I only need an auth key // so no need to generate an image - var myurl = loginData.url + "/index.php?view=watch&mid=" + mid ; + myurl = loginData.url + "/index.php?view=watch&mid=" + mid ; debug("DataModel: Getting auth from " + myurl + " with mid=" + mid); $http.get(myurl) .then(function (success) { |
