diff options
Diffstat (limited to 'www')
| -rwxr-xr-x | www/js/DataModel.js | 32 | ||||
| -rwxr-xr-x | www/js/app.js | 13 |
2 files changed, 36 insertions, 9 deletions
diff --git a/www/js/DataModel.js b/www/js/DataModel.js index ad0ab6e1..2323c27e 100755 --- a/www/js/DataModel.js +++ b/www/js/DataModel.js @@ -176,6 +176,7 @@ angular.module('zmApp.controllers') 'showLiveForInProgressEvents': true, 'disableSimulStreaming': false, 'insertBasicAuthToken': false, + 'loginAPISupported': false, }; @@ -347,7 +348,7 @@ angular.module('zmApp.controllers') // disable for now, getAuthHash needs work - if (versionCompare(currentServerVersion, "1.31.44") != -1) { + if (versionCompare(currentServerVersion, "1.31.44") != -1 || loginData.loginAPISupported) { myurl = loginData.apiurl + '/host/getCredentials.json'; debug("Server version > 1.31.41, so using getCredentials API:" + myurl); @@ -1298,6 +1299,13 @@ angular.module('zmApp.controllers') } + + if (typeof loginData.loginAPISupported == 'undefined') { + + loginData.loginAPISupported = false; + + } + loginData.canSwipeMonitors = true; loginData.forceImageModePath = false; loginData.enableBlog = true; @@ -2629,6 +2637,28 @@ angular.module('zmApp.controllers') log(loginData.url + "=>Logging out of any existing ZM sessions..."); $rootScope.authSession = "undefined"; + + if (versionCompare(currentServerVersion, "1.31.44") != -1 || loginData.loginAPISupported) { + + debug ("Logging out using API method"); + $http.get(loginData.apiurl+'/host/logout.json') + .then (function(s) { + debug ("Logout returned "+JSON.stringify(s)); + d.resolve(true); + return d.promise; + }, + function (e) { + debug ("Logout errored "+JSON.stringify(e)); + d.resolve(true); + return d.promise; + } + ); + return d.promise; + } + + + // old logout mode + debug ("Logging out using Web method"); $http({ method: 'POST', timeout: 10000, diff --git a/www/js/app.js b/www/js/app.js index 752eaaa1..871ed7dd 100755 --- a/www/js/app.js +++ b/www/js/app.js @@ -1063,19 +1063,16 @@ angular.module('zmApp', [ } } + var ld = NVRDataModel.getLogin(); + ld.loginAPISupported = true; + NVRDataModel.setLogin(ld); + NVRDataModel.log("Stream authentication construction: " + $rootScope.authSession); NVRDataModel.log("zmAutologin successfully logged into Zoneminder via API"); - /* - { - "credentials": "auth=fsdfdsfsd, - "append_password": 0, - "version": "1.31.44", - "apiversion": "1.0" - } - */ + d.resolve("Login Success"); |
