diff options
| author | Pliable Pixels <pliablepixels@users.noreply.github.com> | 2019-05-28 16:12:18 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-05-28 16:12:18 -0400 |
| commit | 572d19af26f07d78b99f8e2a0603a57ca066b326 (patch) | |
| tree | 0628ef7a8467cd1124245cf28a59ed5bfda3ad17 /www/js/NVR.js | |
| parent | adb63ae77e1318a1c42dd0fe8ce31cfa7584194b (diff) | |
| parent | 5bf531cfd5aa6812dd96bb3aa887187f71f3f560 (diff) | |
Merge pull request #819 from pliablepixels/api-tokens
Api tokens
Diffstat (limited to 'www/js/NVR.js')
| -rw-r--r-- | www/js/NVR.js | 1168 |
1 files changed, 808 insertions, 360 deletions
diff --git a/www/js/NVR.js b/www/js/NVR.js index 87c76e80..1b5b9da8 100644 --- a/www/js/NVR.js +++ b/www/js/NVR.js @@ -192,11 +192,14 @@ angular.module('zmApp.controllers') 'montageReviewCollapse': true, 'objectDetectionFilter': false, 'enableEventRefresh': true, - 'lastEventCheckTimes':{}, + 'lastEventCheckTimes': {}, 'enableMontageOverlays': true, - 'showMontageSidebars': false - - + 'showMontageSidebars': false, + 'isTokenSupported': false, + 'accessTokenExpires': '', + 'refreshTokenExpires': '', + 'accessToken': '', + 'refreshToken': '' }; @@ -227,7 +230,7 @@ angular.module('zmApp.controllers') cordova.plugin.http.setSSLCertMode('nocheck', function () { debug('--> SSL is permissive, will allow any certs. Use at your own risk.'); }, function () { - console.log('-->Error setting SSL permissive'); + NVR.log('-->Error setting SSL permissive'); }); if ($rootScope.platformOS == 'android') { @@ -311,10 +314,15 @@ angular.module('zmApp.controllers') if (val !== undefined) { var regex1 = /"password":".*?"/g; var regex2 = /&pass=.*?(?=["&]|$)/g; + var regex3 = /&token=([^&]*)/g; + var regex4 = /&auth=([^&]*)/g; + //console.log ("VAL IS " + val); val = val.replace(regex1, "<password removed>"); val = val.replace(regex2, "<password removed>"); + val = val.replace (regex3, "&token=<removed>"); + val = val.replace (regex4, "&auth=<removed>"); } $ionicPlatform.ready(function () { @@ -332,7 +340,7 @@ angular.module('zmApp.controllers') if (configParams.ZM_MIN_STREAMING_PORT == -1 || forceReload) { log("Checking value of ZM_MIN_STREAMING_PORT for the first time"); var apiurl = loginData.apiurl; - var myurl = apiurl + '/configs/viewByName/ZM_MIN_STREAMING_PORT.json'; + var myurl = apiurl + '/configs/viewByName/ZM_MIN_STREAMING_PORT.json?' + $rootScope.authSession; $http.get(myurl) .then(function (data) { data = data.data; @@ -370,6 +378,314 @@ angular.module('zmApp.controllers') } + function proceedWithFreshLogin(noBroadcast) { + + + // recompute rand anyway so even if you don't have auth + // your stream should not get frozen + $rootScope.rand = Math.floor((Math.random() * 100000) + 1); + $rootScope.modalRand = Math.floor((Math.random() * 100000) + 1); + + // console.log ("***** STATENAME IS " + statename); + + var d = $q.defer(); + log("Doing fresh login to ZM"); + var httpDelay = loginData.enableSlowLoading ? zm.largeHttpTimeout : zm.httpTimeout; + + + str = $translate.instant('kAuthenticating'); + + if (str) { + $ionicLoading.show({ + template: str, + noBackdrop: true, + duration: httpDelay + }); + } + + + //first login using new API + $rootScope.authSession = ''; + var loginAPI = loginData.apiurl + '/host/login.json'; + + + $http({ + method: 'post', + url: loginAPI, + timeout: httpDelay, + skipIntercept: true, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + }, + responseType: 'text', + transformResponse: undefined, + transformRequest: function (obj) { + var str = []; + for (var p in obj) + str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p])); + return str.join("&"); + }, + data: { + user: loginData.username, + pass: loginData.password + } + }) + //$http.get(loginAPI) + .then(function (textsucc) { + + $ionicLoading.hide(); + var succ; + try { + + succ = JSON.parse(textsucc.data); + + if (!succ.version) { + debug("API login returned fake success, going back to webscrape"); + + loginData.loginAPISupported = false; + setLogin(loginData); + + loginWebScrape() + .then(function () { + d.resolve("Login Success"); + return d.promise; + }, + function () { + $ionicLoading.hide(); + d.reject("Login Error"); + return (d.promise); + }); + return d.promise; + } + debug("API based login returned. "); + console.log (JSON.stringify(succ)); + setCurrentServerVersion(succ.version); + $ionicLoading.hide(); + //$rootScope.loggedIntoZm = 1; + //console.log ("***** CLEARING AUTHSESSION IN LINE 466"); + $rootScope.authSession = ''; + + if (succ.refresh_token) { + $rootScope.authSession = '&token='+succ.access_token; + log ("New refresh token retrieved: ..."+succ.refresh_token.substr(-5)); + loginData.isTokenSupported = true; + + loginData.accessToken = succ.access_token; + loginData.accessTokenExpires = moment.utc().add(succ.access_token_expires, 'seconds'); + loginData.refreshToken = succ.refresh_token; + + loginData.refreshTokenExpires = moment.utc().add(succ.refresh_token_expires, 'seconds'); + + log ("Current time is: UTC "+moment.utc().format("YYYY-MM-DD hh:mm:ss")); + log ("New refresh token expires on: UTC "+loginData.refreshTokenExpires.format("YYYY-MM-DD hh:mm:ss")); + log ("New access token expires on: UTC "+loginData.accessTokenExpires.format("YYYY-MM-DD hh:mm:ss")); + setLogin(loginData); + + } + 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; + } + } + else { + log ("Neither token nor old cred worked. Seems like an error"); + } + } + + + + loginData.loginAPISupported = true; + setLogin(loginData); + + + log("Stream authentication construction: " + + $rootScope.authSession); + + log("Successfully logged into Zoneminder via API"); + + + + d.resolve("Login Success"); + if (!noBroadcast) $rootScope.$broadcast('auth-success', succ); + return d.promise; + + } catch (e) { + debug("Login API approach did not work..."); + + + loginData.loginAPISupported = false; + loginData.isTokenSupported = false; + setLogin(ld); + loginWebScrape() + .then(function () { + d.resolve("Login Success"); + return d.promise; + }, + function (err) { + $ionicLoading.hide(); + d.reject("Login Error"); + return (d.promise); + }); + return d.promise; + + } + + }, + function (err) { + //console.log("******************* API login error " + JSON.stringify(err)); + $ionicLoading.hide(); + //if (err && err.data && 'success' in err.data) { + NVR.log("API based login not supported, need to use web scraping..."+JSON.stringify(err)); + // login using old web scraping + + loginData.loginAPISupported = false; + setLogin(loginData); + loginWebScrape() + .then(function () { + d.resolve("Login Success"); + return d.promise; + }, + function (err) { + d.reject("Login Error"); + return (d.promise); + }); + + } + ); // post .then + + return d.promise; + + } + + function loginWebScrape(noBroadcast) { + + var d = $q.defer(); + debug("Logging in using old web-scrape method"); + + $ionicLoading.show({ + template: $translate.instant('kAuthenticatingWebScrape'), + noBackdrop: true, + duration: httpDelay + }); + + + + + var httpDelay = loginData.enableSlowLoading ? zm.largeHttpTimeout : zm.httpTimeout; + //NVR.debug ("*** AUTH LOGIN URL IS " + loginData.url); + $http({ + + method: 'post', + timeout: httpDelay, + //withCredentials: true, + url: loginData.url + '/index.php?view=console', + skipIntercept:true, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + 'Accept': 'application/json', + }, + transformRequest: function (obj) { + var str = []; + for (var p in obj) + str.push(encodeURIComponent(p) + "=" + + encodeURIComponent(obj[p])); + var params = str.join("&"); + return params; + }, + + data: { + username: loginData.username, + password: loginData.password, + action: "login", + view: "console" + } + }) + .then(function (data, status, headers) { + // console.log(">>>>>>>>>>>>>> PARALLEL POST SUCCESS"); + data = data.data; + $ionicLoading.hide(); + + // Coming here does not mean success + // it could also be a bad login, but + // ZM returns you to login.php and returns 200 OK + // so we will check if the data has + // <title>ZM - Login</title> -- it it does then its the login page + + if (data.indexOf(zm.loginScreenString1) >=0) { + //eventServer.start(); + //$rootScope.loggedIntoZm = 1; + + log("zmAutologin successfully logged into Zoneminder"); + $rootScope.apiValid = true; + + // now go to authKey part, so don't return yet... + + } else // this means login error + { + // $rootScope.loggedIntoZm = -1; + //console.log("**** ZM Login FAILED"); + log("zmAutologin Error: Bad Credentials ", "error"); + if (!noBroadcast) $rootScope.$broadcast('auth-error', "incorrect credentials"); + + d.reject("Login Error"); + return (d.promise); + // no need to go to next code, so return above + } + + // Now go ahead and re-get auth key + // if login was a success + // console.log ("***** CLEARING AUTHSESSION IN AUTHKEY"); + $rootScope.authSession = ''; + getAuthKey($rootScope.validMonitorId) + .then(function (success) { + + //console.log(success); + //console.log ("***** SETTING AUTHSESSION IN AUTHKEY"+success); + $rootScope.authSession = success; + log("Stream authentication construction: " + + $rootScope.authSession); + d.resolve("Login Success"); + $rootScope.$broadcast('auth-success', data); + return d.promise; + + }, + function (error) { + //console.log(error); + + log("Modal: Error returned Stream authentication construction. Retaining old value of: " + $rootScope.authSession); + debug("Error was: " + JSON.stringify(error)); + d.resolve("Login Success"); + if (!noBroadcast) $rootScope.$broadcast('auth-success', data); + }); + + return (d.promise); + + }, + function (error, status) { + + // console.log(">>>>>>>>>>>>>> PARALLEL POST ERROR"); + $ionicLoading.hide(); + + //console.log("**** ZM Login FAILED"); + + // FIXME: Is this sometimes results in null + + log("zmAutologin Error " + JSON.stringify(error) + " and status " + status); + // bad urls etc come here + //$rootScope.loggedIntoZm = -1; + if (!noBroadcast) $rootScope.$broadcast('auth-error', error); + + d.reject("Login Error"); + return d.promise; + }); + return d.promise; + } function getAuthKey(mid, ck) { @@ -382,6 +698,12 @@ angular.module('zmApp.controllers') return d.promise; } + if ($rootScope.authSession != '' && $rootScope.authSession != 'undefined') { + log("We already have an auth key of:" + $rootScope.authSession); + d.resolve($rootScope.authSession); + return d.promise; + } + if (loginData.currentServerVersion && (versionCompare(loginData.currentServerVersion, zm.versionWithLoginAPI) != -1 || loginData.loginAPISupported)) { myurl = loginData.apiurl + '/host/getCredentials.json'; @@ -391,7 +713,7 @@ angular.module('zmApp.controllers') debug("Credentials API returned: " + JSON.stringify(s)); if (!s.data || !s.data.credentials) { - $rootScope.authSession = "undefined"; + $rootScope.authSession = ""; d.resolve($rootScope.authSession); debug("getCredentials() API Succeded, but did NOT return credentials key: " + JSON.stringify(s)); return d.promise; @@ -408,7 +730,9 @@ angular.module('zmApp.controllers') }, function (e) { - $rootScope.authSession = "undefined"; + + //console.log ("***** CLEARING AUTHSESSION IN GETCREDENTIALS"); + $rootScope.authSession = ""; d.resolve($rootScope.authSession); debug("AuthHash API Error: " + JSON.stringify(e)); return d.promise; @@ -483,10 +807,15 @@ angular.module('zmApp.controllers') if (val !== undefined) { var regex1 = /"password":".*?"/g; var regex2 = /&pass=.*?(?=["&]|$)/g; + var regex3 = /&token=([^&]*)/g; + var regex4 = /&auth=([^&]*)/g; + //console.log ("VAL IS " + val); val = val.replace(regex1, "<password removed>"); val = val.replace(regex2, "<password removed>"); + val = val.replace (regex3, "&token=<removed>"); + val = val.replace (regex4, "&auth=<removed>"); } // make sure password is removed @@ -510,11 +839,10 @@ angular.module('zmApp.controllers') try { positions = JSON.parse(positionsStr); + } catch (e) { + debug("error parsing positions"); } - catch (e) { - debug ("error parsing positions"); - } - + for (var m = 0; m < monitors.length; m++) { var positionFound = false; for (var p = 0; p < positions.length; p++) { @@ -607,464 +935,489 @@ angular.module('zmApp.controllers') } function _checkInitSanity(loginData) { - // old version hacks for new variables - - // always true Oct 27 2016 - loginData.persistMontageOrder = true; - loginData.enableh264 = true; - - if (typeof loginData.isUseBasicAuth === 'undefined') { - loginData.isUseBasicAuth = false; - loginData.basicAuthUser = ''; - loginData.basicAuthPassword = ''; - $rootScope.basicAuthHeader = ''; - $rootScope.basicAuthToken = ''; - } + // old version hacks for new variables + + // always true Oct 27 2016 + loginData.persistMontageOrder = true; + loginData.enableh264 = true; + + if (typeof loginData.isUseBasicAuth === 'undefined') { + loginData.isUseBasicAuth = false; + loginData.basicAuthUser = ''; + loginData.basicAuthPassword = ''; + $rootScope.basicAuthHeader = ''; + $rootScope.basicAuthToken = ''; + } - if (loginData.url.indexOf('@') != -1) { - log(">> " + loginData.url); - log(">>User/Password detected in URL, changing to new auth handling..."); - loginData.isUseBasicAuth = true; + if (loginData.url.indexOf('@') != -1) { + log(">> " + loginData.url); + log(">>User/Password detected in URL, changing to new auth handling..."); + loginData.isUseBasicAuth = true; - var components = URI.parse(loginData.url); - loginData.url = components.scheme + "://" + components.host; - if (components.port) loginData.url = loginData.url + ":" + components.port; - if (components.path) loginData.url = loginData.url + components.path; + var components = URI.parse(loginData.url); + loginData.url = components.scheme + "://" + components.host; + if (components.port) loginData.url = loginData.url + ":" + components.port; + if (components.path) loginData.url = loginData.url + components.path; - components = URI.parse(loginData.streamingurl); - loginData.streamingurl = components.scheme + "://" + components.host; - if (components.port) loginData.streamingurl = loginData.streamingurl + ":" + components.port; - if (components.path) loginData.streamingurl = loginData.streamingurl + components.path; + components = URI.parse(loginData.streamingurl); + loginData.streamingurl = components.scheme + "://" + components.host; + if (components.port) loginData.streamingurl = loginData.streamingurl + ":" + components.port; + if (components.path) loginData.streamingurl = loginData.streamingurl + components.path; - components = URI.parse(loginData.apiurl); - loginData.apiurl = components.scheme + "://" + components.host; - if (components.port) loginData.apiurl = loginData.apiurl + ":" + components.port; - if (components.path) loginData.apiurl = loginData.apiurl + components.path; + components = URI.parse(loginData.apiurl); + loginData.apiurl = components.scheme + "://" + components.host; + if (components.port) loginData.apiurl = loginData.apiurl + ":" + components.port; + if (components.path) loginData.apiurl = loginData.apiurl + components.path; - $rootScope.basicAuthToken = btoa(components.userinfo); - $rootScope.basicAuthHeader = 'Basic ' + $rootScope.basicAuthToken; - //console.log (">>>> SET BASIC AUTH TO " + $rootScope.basicAuthHeader); + $rootScope.basicAuthToken = btoa(components.userinfo); + $rootScope.basicAuthHeader = 'Basic ' + $rootScope.basicAuthToken; + //console.log (">>>> SET BASIC AUTH TO " + $rootScope.basicAuthHeader); - var up = components.userinfo.split(':'); - loginData.basicAuthPassword = up[1]; - loginData.basicAuthUser = up[0]; - //console.log ("SETTING "+loginData.basicAuthUser+" "+loginData.basicAuthPassword); + var up = components.userinfo.split(':'); + loginData.basicAuthPassword = up[1]; + loginData.basicAuthUser = up[0]; + //console.log ("SETTING "+loginData.basicAuthUser+" "+loginData.basicAuthPassword); - } + } - if (loginData.isUseBasicAuth) { - $rootScope.basicAuthToken = btoa(loginData.basicAuthUser + ':' + loginData.basicAuthPassword); - $rootScope.basicAuthHeader = 'Basic ' + $rootScope.basicAuthToken; - debug("Basic authentication detected, constructing Authorization Header"); + if (loginData.isUseBasicAuth) { + $rootScope.basicAuthToken = btoa(loginData.basicAuthUser + ':' + loginData.basicAuthPassword); + $rootScope.basicAuthHeader = 'Basic ' + $rootScope.basicAuthToken; + debug("Basic authentication detected, constructing Authorization Header"); - // console.log ("BASIC AUTH SET TO:"+$rootScope.basicAuthHeader); + // console.log ("BASIC AUTH SET TO:"+$rootScope.basicAuthHeader); - } + } - if (typeof loginData.enableAlarmCount === 'undefined') { - debug("enableAlarmCount does not exist, setting to true"); - loginData.enableAlarmCount = true; - } + if (typeof loginData.enableAlarmCount === 'undefined') { + debug("enableAlarmCount does not exist, setting to true"); + loginData.enableAlarmCount = true; + } - if (typeof loginData.onTapScreen == 'undefined') { - loginData.onTapScreen = $translate.instant('kTapMontage'); - } + if (typeof loginData.onTapScreen == 'undefined') { + loginData.onTapScreen = $translate.instant('kTapMontage'); + } - if (loginData.onTapScreen != $translate.instant('kTapMontage') && - loginData.onTapScreen != $translate.instant('kTapEvents') && - loginData.onTapScreen != $translate.instant('kTapLiveMonitor')) { - log("Invalid onTap setting found, resetting. I got " + loginData.onTapScreen); - loginData.onTapScreen = $translate.instant('kMontage'); - } + if (loginData.onTapScreen != $translate.instant('kTapMontage') && + loginData.onTapScreen != $translate.instant('kTapEvents') && + loginData.onTapScreen != $translate.instant('kTapLiveMonitor')) { + log("Invalid onTap setting found, resetting. I got " + loginData.onTapScreen); + loginData.onTapScreen = $translate.instant('kMontage'); + } - if (typeof loginData.minAlarmCount === 'undefined') { - debug("minAlarmCount does not exist, setting to true"); - loginData.minAlarmCount = 1; - } + if (typeof loginData.minAlarmCount === 'undefined') { + debug("minAlarmCount does not exist, setting to true"); + loginData.minAlarmCount = 1; + } - if (typeof loginData.montageSize == 'undefined') { - debug("montageSize does not exist, setting to 2 (2 per col)"); - loginData.montageSize = 2; - } + if (typeof loginData.montageSize == 'undefined') { + debug("montageSize does not exist, setting to 2 (2 per col)"); + loginData.montageSize = 2; + } - if (typeof loginData.useNphZms == 'undefined') { - debug("useNphZms does not exist. Setting to true"); - loginData.useNphZms = true; - } + if (typeof loginData.useNphZms == 'undefined') { + debug("useNphZms does not exist. Setting to true"); + loginData.useNphZms = true; + } - if (typeof loginData.useNphZmsForEvents == 'undefined') { - debug("useNphZmsForEvents does not exist. Setting to true"); - loginData.useNphZmsForEvents = true; - } + if (typeof loginData.useNphZmsForEvents == 'undefined') { + debug("useNphZmsForEvents does not exist. Setting to true"); + loginData.useNphZmsForEvents = true; + } - if (typeof loginData.forceImageModePath == 'undefined') { - debug("forceImageModePath does not exist. Setting to false"); - loginData.forceImageModePath = false; - } + if (typeof loginData.forceImageModePath == 'undefined') { + debug("forceImageModePath does not exist. Setting to false"); + loginData.forceImageModePath = false; + } - if (typeof loginData.reachability == 'undefined') { - debug("reachability does not exist. Setting to true"); - loginData.reachability = true; - } + if (typeof loginData.reachability == 'undefined') { + debug("reachability does not exist. Setting to true"); + loginData.reachability = true; + } - // force it - this may not be the problem - loginData.reachability = true; + // force it - this may not be the problem + loginData.reachability = true; - // and now, force enable it - loginData.useNphZms = true; - loginData.useNphZmsForEvents = true; + // and now, force enable it + loginData.useNphZms = true; + loginData.useNphZmsForEvents = true; - if (typeof loginData.packMontage == 'undefined') { - debug("packMontage does not exist. Setting to false"); - loginData.packMontage = false; - } + if (typeof loginData.packMontage == 'undefined') { + debug("packMontage does not exist. Setting to false"); + loginData.packMontage = false; + } - if (typeof loginData.forceNetworkStop == 'undefined') { - debug("forceNetwork does not exist. Setting to false"); - loginData.forceNetworkStop = false; - } + if (typeof loginData.forceNetworkStop == 'undefined') { + debug("forceNetwork does not exist. Setting to false"); + loginData.forceNetworkStop = false; + } - if (typeof loginData.enableLogs == 'undefined') { - debug("enableLogs does not exist. Setting to true"); - loginData.enableLogs = true; - } + if (typeof loginData.enableLogs == 'undefined') { + debug("enableLogs does not exist. Setting to true"); + loginData.enableLogs = true; + } - if (typeof loginData.defaultPushSound == 'undefined') { - debug("defaultPushSound does not exist. Setting to false"); - loginData.defaultPushSound = false; - } + if (typeof loginData.defaultPushSound == 'undefined') { + debug("defaultPushSound does not exist. Setting to false"); + loginData.defaultPushSound = false; + } - //console.log("INIT SIMUL=" + loginData.disableSimulStreaming); - //console.log("INIT PLATFORM IS=" + $rootScope.platformOS); - if (typeof loginData.disableSimulStreaming == 'undefined') { + //console.log("INIT SIMUL=" + loginData.disableSimulStreaming); + //console.log("INIT PLATFORM IS=" + $rootScope.platformOS); + if (typeof loginData.disableSimulStreaming == 'undefined') { - loginData.disableSimulStreaming = false; - //console.log("INIT DISABLING SIMUL:" + loginData.disableSimulStreaming); - } + loginData.disableSimulStreaming = false; + //console.log("INIT DISABLING SIMUL:" + loginData.disableSimulStreaming); + } - if (typeof loginData.exitOnSleep == 'undefined') { - debug("exitOnSleep does not exist. Setting to false"); - loginData.exitOnSleep = false; - } + if (typeof loginData.exitOnSleep == 'undefined') { + debug("exitOnSleep does not exist. Setting to false"); + loginData.exitOnSleep = false; + } - if (typeof loginData.enableBlog == 'undefined') { - debug("enableBlog does not exist. Setting to true"); - loginData.enableBlog = true; + if (typeof loginData.enableBlog == 'undefined') { + debug("enableBlog does not exist. Setting to true"); + loginData.enableBlog = true; - } + } - if (typeof loginData.packeryPositionsArray == 'undefined') { - debug("packeryPositionsArray does not exist. Setting to empty"); - loginData.packeryPositionsArray = {}; + if (typeof loginData.packeryPositionsArray == 'undefined') { + debug("packeryPositionsArray does not exist. Setting to empty"); + loginData.packeryPositionsArray = {}; - } + } - if (typeof loginData.packeryPositions == 'undefined') { - debug("packeryPositions does not exist. Setting to empty"); - loginData.packeryPositions = ""; + if (typeof loginData.packeryPositions == 'undefined') { + debug("packeryPositions does not exist. Setting to empty"); + loginData.packeryPositions = ""; - } + } - if (typeof loginData.EHpackeryPositions == 'undefined') { - debug("EHpackeryPositions does not exist. Setting to empty"); - loginData.EHpackeryPositions = ""; + if (typeof loginData.EHpackeryPositions == 'undefined') { + //debug("EHpackeryPositions does not exist. Setting to empty"); + loginData.EHpackeryPositions = ""; - } + } - if (typeof loginData.packerySizes == 'undefined') { - debug("packerySizes does not exist. Setting to empty"); - loginData.packerySizes = ""; + if (typeof loginData.packerySizes == 'undefined') { + //debug("packerySizes does not exist. Setting to empty"); + loginData.packerySizes = ""; - } + } - if (typeof loginData.use24hr == 'undefined') { - debug("use24hr does not exist. Setting to false"); - loginData.use24hr = false; + if (typeof loginData.use24hr == 'undefined') { + //debug("use24hr does not exist. Setting to false"); + loginData.use24hr = false; - } + } - if (typeof timelineModalGraphType == 'undefined') { - debug("timeline graph type not set. Setting to all"); - loginData.timelineModalGraphType = $translate.instant('kGraphAll'); - //console.log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" + loginData.timelineModalGraphType); - } + if (typeof timelineModalGraphType == 'undefined') { + //debug("timeline graph type not set. Setting to all"); + loginData.timelineModalGraphType = $translate.instant('kGraphAll'); + //console.log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" + loginData.timelineModalGraphType); + } - if (typeof loginData.resumeDelay == 'undefined') { - debug("resumeDelay does not exist. Setting to 0"); - loginData.resumeDelay = 0; + if (typeof loginData.resumeDelay == 'undefined') { + //debug("resumeDelay does not exist. Setting to 0"); + loginData.resumeDelay = 0; - } - // override resumeDelay - it was developed on a wrong assumption - loginData.resumeDelay = 0; + } + // override resumeDelay - it was developed on a wrong assumption + loginData.resumeDelay = 0; - if (typeof loginData.montageHistoryQuality == 'undefined') { - debug("montageHistoryQuality does not exist. Setting to 50"); - loginData.montageHistoryQuality = "50"; + if (typeof loginData.montageHistoryQuality == 'undefined') { + debug("montageHistoryQuality does not exist. Setting to 50"); + loginData.montageHistoryQuality = "50"; - } + } - if (typeof loginData.vibrateOnPush == 'undefined') { - debug("vibrate on push not found, setting to true"); - loginData.vibrateOnPush = true; + if (typeof loginData.vibrateOnPush == 'undefined') { + debug("vibrate on push not found, setting to true"); + loginData.vibrateOnPush = true; - } + } - if (typeof loginData.isFullScreen == 'undefined') { + if (typeof loginData.isFullScreen == 'undefined') { - loginData.isFullScreen = false; + loginData.isFullScreen = false; - } + } - if (typeof loginData.reloadInMontage == 'undefined') { + if (typeof loginData.reloadInMontage == 'undefined') { - loginData.reloadInMontage = false; + loginData.reloadInMontage = false; - } + } - if (typeof loginData.soundOnPush == 'undefined') { - debug("sound on push not found, setting to true"); - loginData.soundOnPush = true; + if (typeof loginData.soundOnPush == 'undefined') { + debug("sound on push not found, setting to true"); + loginData.soundOnPush = true; - } + } - if (typeof loginData.cycleMonitors == 'undefined') { + if (typeof loginData.cycleMonitors == 'undefined') { - loginData.cycleMonitors = false; + loginData.cycleMonitors = false; - } + } - if (typeof loginData.cycleMonitorsInterval == 'undefined') { + if (typeof loginData.cycleMonitorsInterval == 'undefined') { - loginData.cycleMonitorsInterval = 10; + loginData.cycleMonitorsInterval = 10; - } + } - if (typeof loginData.cycleMontage == 'undefined') { + if (typeof loginData.cycleMontage == 'undefined') { - loginData.cycleMontage = false; + loginData.cycleMontage = false; - } + } - if (typeof loginData.cycleMontageInterval == 'undefined') { + if (typeof loginData.cycleMontageInterval == 'undefined') { - loginData.cycleMontageInterval = 10; + loginData.cycleMontageInterval = 10; - } + } - if (typeof loginData.enableLowBandwidth == 'undefined') { + if (typeof loginData.enableLowBandwidth == 'undefined') { - loginData.enableLowBandwidth = false; + loginData.enableLowBandwidth = false; - } - // wtf is wrong with this ternary? - //$rootScope.runMode = (loginData.enableLowBandwith==true)? "low": "normal"; + } + - if (typeof loginData.autoSwitchBandwidth == 'undefined') { + if (typeof loginData.autoSwitchBandwidth == 'undefined') { - loginData.autoSwitchBandwidth = false; + loginData.autoSwitchBandwidth = false; - } + } - $rootScope.runMode = getBandwidth(); - log("Setting NVR init bandwidth to: " + $rootScope.runMode); + $rootScope.runMode = getBandwidth(); + log("Setting NVR init bandwidth to: " + $rootScope.runMode); - if (typeof loginData.refreshSecLowBW == 'undefined') { + if (typeof loginData.refreshSecLowBW == 'undefined') { - loginData.refreshSecLowBW = 8; + loginData.refreshSecLowBW = 8; - } + } - if (typeof loginData.disableAlarmCheckMontage == 'undefined') { + if (typeof loginData.disableAlarmCheckMontage == 'undefined') { - loginData.disableAlarmCheckMontage = false; + loginData.disableAlarmCheckMontage = false; - } + } - if (typeof loginData.useLocalTimeZone == 'undefined') { + if (typeof loginData.useLocalTimeZone == 'undefined') { - loginData.useLocalTimeZone = true; + loginData.useLocalTimeZone = true; - } + } - if (typeof loginData.fastLogin == 'undefined') { + if (typeof loginData.fastLogin == 'undefined') { - loginData.fastLogin = true; + loginData.fastLogin = true; - } + } - if (typeof loginData.currentMontageProfile == 'undefined') { + if (typeof loginData.currentMontageProfile == 'undefined') { - loginData.currentMontageProfile = ''; + loginData.currentMontageProfile = ''; - } + } - if (typeof loginData.followTimeLine == 'undefined') { + if (typeof loginData.followTimeLine == 'undefined') { - loginData.followTimeLine = false; + loginData.followTimeLine = false; - } + } - if (typeof loginData.timelineScale == 'undefined') { + if (typeof loginData.timelineScale == 'undefined') { - loginData.timelineScale = -1; + loginData.timelineScale = -1; - } + } - if (typeof loginData.showMontageSubMenu == 'undefined') { + if (typeof loginData.showMontageSubMenu == 'undefined') { - loginData.showMontageSubMenu = false; + loginData.showMontageSubMenu = false; - } + } - if (typeof loginData.monSingleImageQuality == 'undefined') { + if (typeof loginData.monSingleImageQuality == 'undefined') { - loginData.monSingleImageQuality = 100; + loginData.monSingleImageQuality = 100; - } + } - if (typeof loginData.hideArchived == 'undefined') { + if (typeof loginData.hideArchived == 'undefined') { - loginData.hideArchived = false; + loginData.hideArchived = false; - } + } - if (typeof loginData.videoPlaybackSpeed == 'undefined') { + if (typeof loginData.videoPlaybackSpeed == 'undefined') { - loginData.videoPlaybackSpeed = 1; + loginData.videoPlaybackSpeed = 1; - } + } - if (typeof loginData.enableThumbs == 'undefined') { + if (typeof loginData.enableThumbs == 'undefined') { - loginData.enableThumbs = true; + loginData.enableThumbs = true; - } + } - if (typeof loginData.enableSlowLoading == 'undefined') { + if (typeof loginData.enableSlowLoading == 'undefined') { - loginData.enableSlowLoading = false; + loginData.enableSlowLoading = false; - } + } - if (typeof loginData.enableStrictSSL == 'undefined') { + if (typeof loginData.enableStrictSSL == 'undefined') { - loginData.enableStrictSSL = false; + loginData.enableStrictSSL = false; - } + } - if (typeof loginData.momentGridSize == 'undefined') { + if (typeof loginData.momentGridSize == 'undefined') { - loginData.momentGridSize = 40; + loginData.momentGridSize = 40; - } + } - if (typeof loginData.enableMomentSubMenu == 'undefined') { + if (typeof loginData.enableMomentSubMenu == 'undefined') { - loginData.enableMomentSubMenu = true; + loginData.enableMomentSubMenu = true; - } + } - if (typeof loginData.momentMonitorFilter == 'undefined') { + if (typeof loginData.momentMonitorFilter == 'undefined') { - loginData.momentMonitorFilter = JSON.stringify([]); + loginData.momentMonitorFilter = JSON.stringify([]); - } + } - if (typeof loginData.momentArrangeBy == 'undefined') { + if (typeof loginData.momentArrangeBy == 'undefined') { - loginData.momentArrangeBy = "StartTime"; + loginData.momentArrangeBy = "StartTime"; - } + } - if (typeof loginData.insertBasicAuthToken == 'undefined') { + if (typeof loginData.insertBasicAuthToken == 'undefined') { - loginData.insertBasicAuthToken = false; + loginData.insertBasicAuthToken = false; - } + } - if (typeof loginData.showLiveForInProgressEvents == 'undefined') { + if (typeof loginData.showLiveForInProgressEvents == 'undefined') { - loginData.showLiveForInProgressEvents = true; + loginData.showLiveForInProgressEvents = true; - } + } - if (typeof loginData.loginAPISupported == 'undefined') { + if (typeof loginData.loginAPISupported == 'undefined') { - loginData.loginAPISupported = false; + loginData.loginAPISupported = false; - } + } - if (typeof loginData.montageResizeSteps == 'undefined') { + if (typeof loginData.montageResizeSteps == 'undefined') { - loginData.montageResizeSteps = 5; + loginData.montageResizeSteps = 5; - } + } - if (typeof loginData.saveToCloud == 'undefined') { + if (typeof loginData.saveToCloud == 'undefined') { - loginData.saveToCloud = true; + loginData.saveToCloud = true; - } + } - if (typeof loginData.montageReviewCollapse == 'undefined') { + if (typeof loginData.montageReviewCollapse == 'undefined') { - loginData.montageReviewCollapse = true; + loginData.montageReviewCollapse = true; - } + } - if (typeof loginData.objectDetectionFilter == 'undefined') { + if (typeof loginData.objectDetectionFilter == 'undefined') { - loginData.objectDetectionFilter = false; + loginData.objectDetectionFilter = false; - } + } - if (typeof loginData.enableEventRefresh == 'undefined') { + if (typeof loginData.enableEventRefresh == 'undefined') { - loginData.enableEventRefresh = true; + loginData.enableEventRefresh = true; - } + } - - - if (typeof loginData.lastEventCheckTimes == 'undefined') { - loginData.lastEventCheckTimes = {}; - } + if (typeof loginData.lastEventCheckTimes == 'undefined') { + loginData.lastEventCheckTimes = {}; - if (typeof loginData.enableMontageOverlays == 'undefined') { - loginData.enableMontageOverlays = true; + } - } - if (typeof loginData.showMontageSidebars == 'undefined') { - loginData.showMontageSidebars = false; + if (typeof loginData.enableMontageOverlays == 'undefined') { + loginData.enableMontageOverlays = true; - } + } + + if (typeof loginData.showMontageSidebars == 'undefined') { + loginData.showMontageSidebars = false; + + } - loginData.canSwipeMonitors = true; - loginData.forceImageModePath = false; - loginData.enableBlog = true; + if (typeof loginData.isTokenSupported == 'undefined') { + loginData.isTokenSupported = false; + + } + + if (typeof loginData.accessTokenExpires == 'undefined') { + loginData.accessTokenExpires = ''; + + } + + if (typeof loginData.refreshTokenExpires == 'undefined') { + loginData.refreshTokenExpires = ''; + + } + + if (typeof loginData.refreshToken == 'undefined') { + loginData.refreshToken = ''; + + } + + if (typeof loginData.accessToken == 'undefined') { + loginData.accessToken = ''; + + } + + + loginData.canSwipeMonitors = true; + loginData.forceImageModePath = false; + loginData.enableBlog = true; } @@ -1496,7 +1849,7 @@ angular.module('zmApp.controllers') }, checkInitSanity: function (l) { - _checkInitSanity(l); + _checkInitSanity(l); }, init: function () { @@ -1830,12 +2183,12 @@ angular.module('zmApp.controllers') getAPIversion: function () { var d = $q.defer(); - var apiurl = loginData.apiurl + '/host/getVersion.json'; + var apiurl = loginData.apiurl + '/host/getVersion.json?' + $rootScope.authSession; debug("getAPIversion called with " + apiurl); $http.get(apiurl) .then(function (success) { if (success.data.version) { - console.log("API VERSION RETURNED: " + JSON.stringify(success)); + //console.log("API VERSION RETURNED: " + JSON.stringify(success)); $rootScope.apiValid = true; if (versionCompare(success.data.version, '1.32.0') != -1) { @@ -1848,12 +2201,7 @@ angular.module('zmApp.controllers') setCurrentServerVersion(success.data.version); debug("getAPI version succeeded with " + success.data.version); d.resolve(success.data.version); - } else { - debug("Setting APIValid to false as API version was not retrieved"); - $rootScope.apiValid = false; - setCurrentServerVersion(""); - d.reject("-1.-1.-1"); - } + } return (d.promise); }, @@ -1942,7 +2290,7 @@ angular.module('zmApp.controllers') getAuthHashLogin: function () { - return $http.get(loginData.apiurl + '/configs/viewByName/ZM_AUTH_HASH_LOGINS.json'); + return $http.get(loginData.apiurl + '/configs/viewByName/ZM_AUTH_HASH_LOGINS.json?' + $rootScope.authSession); }, @@ -1952,7 +2300,7 @@ angular.module('zmApp.controllers') if (forceReload == 1 || configParams.ZM_EVENT_IMAGE_DIGITS == '-1') { var apiurl = loginData.apiurl; - var myurl = apiurl + '/configs/viewByName/ZM_EVENT_IMAGE_DIGITS.json'; + var myurl = apiurl + '/configs/viewByName/ZM_EVENT_IMAGE_DIGITS.json?' + $rootScope.authSession; //debug("Config URL for digits is:" + myurl); $http.get(myurl) .then(function (data) { @@ -1989,7 +2337,7 @@ angular.module('zmApp.controllers') var apiurl = loginData.apiurl; - var myurl = apiurl + '/configs/viewByName/ZM_PATH_ZMS.json'; + var myurl = apiurl + '/configs/viewByName/ZM_PATH_ZMS.json?' + $rootScope.authSession; debug("Config URL for ZMS PATH is:" + myurl); $http.get(myurl) .then(function (data) { @@ -2109,49 +2457,7 @@ angular.module('zmApp.controllers') ); }, - /*killStream: function (ck) { - debug ("Killing connKey: "+ck); - var myauthtoken = $rootScope.authSession.replace("&auth=", ""); - var req = $http( - { - method: 'POST', - - url: loginData.url + '/index.php', - headers: - { - 'Content-Type': 'application/x-www-form-urlencoded', - , - }, - transformRequest: function(obj) - { - var str = []; - for (var p in obj) - str.push(encodeURIComponent(p) + "=" + - encodeURIComponent(obj[p])); - var foo = str.join("&"); - //console.log("****RETURNING " + foo); - return foo; - }, - - data: - { - view: "request", - request: "stream", - connkey: ck, - command: 3, - auth: myauthtoken, - - } - }) - .then (function (succ) { - console.log ("STOP/KILL OK WITH: " + JSON.stringify(succ)); - }, - function (err) { - console.log ("KILL ERROR WITH: " + JSON.stringify(err)); - }); - - - },*/ + getMultiServersCached: function () { return multiservers; @@ -2159,7 +2465,7 @@ angular.module('zmApp.controllers') // use non cached for daemon status getMultiServers: function () { - return $http.get(loginData.apiurl + '/servers.json'); + return $http.get(loginData.apiurl + '/servers.json?' + $rootScope.authSession); }, @@ -2204,7 +2510,7 @@ angular.module('zmApp.controllers') log((forceReload == 1) ? "getMonitors:Force reloading all monitors" : "getMonitors:Loading all monitors"); var apiurl = loginData.apiurl; var myurl = apiurl + "/monitors"; - myurl += "/index/Type !=:WebSite.json"; + myurl += "/index/Type !=:WebSite.json?" + $rootScope.authSession; getZmsMultiPortSupport() .then(function (zmsPort) { @@ -2220,7 +2526,7 @@ angular.module('zmApp.controllers') if (data.monitors) monitors = data.monitors; - if ($rootScope.authSession == 'undefined') { + if ($rootScope.authSession == '') { log("Now that we have monitors, lets get AuthKey..."); getAuthKey(monitors[0].Monitor.Id, (Math.floor((Math.random() * 999999) + 1)).toString()); } @@ -2234,12 +2540,12 @@ angular.module('zmApp.controllers') debug("Inside getMonitors, will also regen connkeys"); debug("Now trying to get multi-server data, if present"); - $http.get(apiurl + "/servers.json") + $http.get(apiurl + "/servers.json?" + $rootScope.authSession) .then(function (data) { data = data.data; // We found a server list API, so lets make sure // we get the hostname as it will be needed for playback - log("multi server list loaded:" + JSON.stringify(data)); + log("multi server list loaded"); multiservers = data.servers; var multiserver_scheme = "http://"; @@ -2309,8 +2615,8 @@ angular.module('zmApp.controllers') debug("recording server reported is " + JSON.stringify(m)); - debug("portal parsed is " + JSON.stringify(p)); - debug("streaming url parsed is " + JSON.stringify(s)); + //debug("portal parsed is " + JSON.stringify(p)); + //debug("streaming url parsed is " + JSON.stringify(s)); debug("multi-port is:" + zmsPort); var st = ""; @@ -2350,7 +2656,7 @@ angular.module('zmApp.controllers') var sport = parseInt(zmsPort) + parseInt(monitors[i].Monitor.Id); st = st + ':' + sport; } - + } baseurl = st; @@ -2500,9 +2806,141 @@ angular.module('zmApp.controllers') }, + proceedWithLogin: function (obj) { + + var noBroadcast = false; + var tryAccess = true; + var tryRefresh = true; + + if (obj) { + noBroadcast = obj.nobroadcast; + tryAccess = obj.access; + tryRefresh = obj.refresh; + + } + + var d = $q.defer(); + + // This is a good time to check if auth is used :-p + if (!loginData.isUseAuth) { + log("Auth is disabled, setting authSession to empty"); + $rootScope.apiValid = true; + $rootScope.authSession = ''; + d.resolve("Login Success"); + + if (!noBroadcast) $rootScope.$broadcast('auth-success', 'no auth'); + return (d.promise); + + } + + + // lets first try tokens and stored tokens + if (loginData.isTokenSupported) + { + log ("Detected token login supported"); + var now = moment.utc(); + var diff_access = moment.utc(loginData.accessTokenExpires).diff(now, 'minutes'); + var diff_refresh = moment.utc(loginData.refreshTokenExpires).diff(now, 'minutes'); + + // first see if we can work with access token + if (moment.utc(loginData.accessTokenExpires).isAfter(now) && diff_access >=zm.accessTokenLeewayMin && tryAccess) { + log ("Access token still has "+diff_access+" minutes left, using it"); + // console.log ("**************** TOKEN SET="+loginData.accessToken); + $rootScope.authSession = '&token='+loginData.accessToken; + d.resolve("Login success via access token"); + if (!noBroadcast) $rootScope.$broadcast('auth-success', '' ); + return d.promise; + } + // then see if we have at least 30 mins left for refresh token + else if (moment.utc(loginData.refreshTokenExpires).isAfter(now) && diff_refresh >=zm.refreshTokenLeewayMin && tryRefresh) { + log ("Refresh token still has "+diff_refresh+" minutes left, using it"); + var loginAPI = loginData.apiurl + '/host/login.json?token='+loginData.refreshToken; + $http({ + method:'GET', + url: loginAPI, + skipIntercept:true, + }) + .then (function (succ) { + succ = succ.data; + if (succ.access_token) { + + // console.log ("**************** TOKEN SET="+succ.access_token); + $rootScope.authSession = '&token='+succ.access_token; + log ("New access token retrieved: ..."+succ.access_token.substr(-5)); + loginData.accessToken = succ.access_token; + loginData.accessTokenExpires = moment.utc().add(succ.access_token_expires,'seconds'); + log ("Current time is: UTC "+moment.utc().format("YYYY-MM-DD hh:mm:ss")); + log ("New access token expires on: UTC "+loginData.accessTokenExpires.format("YYYY-MM-DD hh:mm:ss")); + log ("New access token expires on:"+loginData.accessTokenExpires.format("YYYY-MM-DD hh:mm:ss")); + loginData.isTokenSupported = true; + setLogin(loginData); + d.resolve("Login success via refresh token"); + if (!noBroadcast) $rootScope.$broadcast('auth-success', '' ); + return d.promise; + } + else { + log ('ERROR:Trying to refresh with refresh token:'+JSON.stringify(succ)); + return proceedWithFreshLogin(noBroadcast) + .then (function (succ) { + d.resolve(succ); + return (d.promise); + }, + function(err) { + d.resolve(err); + return (d.promise); + }); + + } + }, + function (err) { + log ('access token login HTTP failed with: '+JSON.stringify(err)); + return proceedWithFreshLogin(noBroadcast) + .then (function (succ) { + d.resolve(succ); + return (d.promise); + }, + function(err) { + d.resolve(err); + return (d.promise);}); + }); + } // valid refresh + else { + log ('both access and refresh tokens are expired, using a fresh login'); + return proceedWithFreshLogin(noBroadcast) + .then (function (succ) { + d.resolve(succ); + return (d.promise); + }, + function(err) { + d.resolve(err); + return (d.promise); + }); + } + + } // is token supported + else { + log ("Token login not being used"); + // coming here means token reloads fell through + return proceedWithFreshLogin(noBroadcast) + .then (function (succ) { + d.resolve(succ); + return (d.promise); + }, + function(err) { + d.resolve(err); + return (d.promise); + }); + } + return (d.promise); + + }, + + + + zmPrivacyProcessed: function () { var apiurl = loginData.apiurl; - var myurl = apiurl + '/configs/viewByName/ZM_SHOW_PRIVACY.json'; + var myurl = apiurl + '/configs/viewByName/ZM_SHOW_PRIVACY.json?' + $rootScope.authSession; var d = $q.defer(); $http({ @@ -2603,6 +3041,7 @@ angular.module('zmApp.controllers') } return d.promise; }, + // returns if this mid is hidden or not isNotHidden: function (mid) { @@ -2641,7 +3080,7 @@ angular.module('zmApp.controllers') if (!tz || isForce) { log("First invocation of TimeZone, asking server"); - var apiurl = loginData.apiurl + '/host/getTimeZone.json'; + var apiurl = loginData.apiurl + '/host/getTimeZone.json?' + $rootScope.authSession; $http.get(apiurl) .then(function (success) { tz = success.data.tz; @@ -2700,11 +3139,11 @@ angular.module('zmApp.controllers') //https:///zm/api/events/index/Notes%20REGEXP:detected%3A.json if (loginData.objectDetectionFilter && !noObjectFilter) { - myurl = myurl + '/Notes%20REGEXP:detected%3A'; + myurl = myurl + '/Notes REGEXP:detected:'; } - myurl = myurl + ".json"; + myurl = myurl + ".json?" + $rootScope.authSession; //console.log (">>>>>Constructed URL " + myurl); $ionicLoading.show({ @@ -2787,12 +3226,13 @@ angular.module('zmApp.controllers') myurl = myurl + "/AlarmFrames >=:" + (loginData.enableAlarmCount ? loginData.minAlarmCount : 0); + // don't know why but adding page messes up Notes //https:///zm/api/events/index/Notes%20REGEXP: detected%3A.json if (loginData.objectDetectionFilter && !noObjectFilter) { myurl = myurl + '/Notes REGEXP:detected:'; } - myurl = myurl + ".json?&sort=StartTime&direction=desc&page=" + pageId; + myurl = myurl + ".json?&sort=StartTime&direction=desc&page=" + pageId + $rootScope.authSession; debug("getEvents:" + myurl); @@ -2807,6 +3247,8 @@ angular.module('zmApp.controllers') data = data.data; if (loadingStr != 'none') $ionicLoading.hide(); //myevents = data.events; + + myevents = data; @@ -3056,8 +3498,14 @@ angular.module('zmApp.controllers') }, logout: function () { + var d = $q.defer(); // always resolves + if (!loginData.isUseAuth || loginData.isTokenSupported) { + log("No need for logout!"); + d.resolve(true); + return d.promise; + } $ionicLoading.show({ template: $translate.instant('kCleaningUp'), @@ -3065,9 +3513,9 @@ angular.module('zmApp.controllers') }); - var d = $q.defer(); + log(loginData.url + "=>Logging out of any existing ZM sessions..."); - $rootScope.authSession = "undefined"; + $rootScope.authSession = ""; // console.log("CURRENT SERVER: " + loginData.currentServerVersion); |
