summaryrefslogtreecommitdiff
path: root/www/js/LoginCtrl.js
diff options
context:
space:
mode:
authorPliable Pixels <pliablepixels@users.noreply.github.com>2019-05-28 16:12:18 -0400
committerGitHub <noreply@github.com>2019-05-28 16:12:18 -0400
commit572d19af26f07d78b99f8e2a0603a57ca066b326 (patch)
tree0628ef7a8467cd1124245cf28a59ed5bfda3ad17 /www/js/LoginCtrl.js
parentadb63ae77e1318a1c42dd0fe8ce31cfa7584194b (diff)
parent5bf531cfd5aa6812dd96bb3aa887187f71f3f560 (diff)
Merge pull request #819 from pliablepixels/api-tokens
Api tokens
Diffstat (limited to 'www/js/LoginCtrl.js')
-rw-r--r--www/js/LoginCtrl.js109
1 files changed, 28 insertions, 81 deletions
diff --git a/www/js/LoginCtrl.js b/www/js/LoginCtrl.js
index 36eac47d..9e369f02 100644
--- a/www/js/LoginCtrl.js
+++ b/www/js/LoginCtrl.js
@@ -610,9 +610,8 @@ function mobilePinConfig () {
// don't do it for WSS - lets mandate that
}*/
- var apiurl = $scope.loginData.apiurl + '/host/getVersion.json';
- var portalurl = $scope.loginData.url + '/index.php';
-
+ var apiurl = $scope.loginData.apiurl + '/host/getVersion.json?'+$rootScope.authSession;
+
// Check if isUseAuth is set make sure u/p have a dummy value
if ($scope.loginData.isUseAuth) {
if (!$scope.loginData.username) $scope.loginData.username = "x";
@@ -654,6 +653,7 @@ function mobilePinConfig () {
$rootScope.authSession = '';
+ //console.log ("***** CLEARING AUTHSESSION IN SAVEITEMS");
if ($rootScope.platformOS != 'desktop') {
@@ -669,7 +669,7 @@ function mobilePinConfig () {
cordova.plugin.http.setSSLCertMode('nocheck', function () {
NVR.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') {
@@ -769,7 +769,7 @@ function mobilePinConfig () {
if ($scope.loginData.serverName != NVR.getLogin().serverName) {
NVR.debug(">>> Server information has changed, likely a fallback took over!");
$scope.loginData = NVR.getLogin();
- apiurl = $scope.loginData.apiurl + '/host/getVersion.json';
+ apiurl = $scope.loginData.apiurl + '/host/getVersion.json?'+$rootScope.authSession;
portalurl = $scope.loginData.url + '/index.php';
}
@@ -785,85 +785,32 @@ function mobilePinConfig () {
var loginStatus = $translate.instant('kExploreEnjoy') + " " + $rootScope.appName + "!";
EventServer.refresh();
- // now grab and report PATH_ZMS
- NVR.getPathZms()
+ NVR.debug("refreshing API version...");
+ NVR.getAPIversion()
.then(function (data) {
- var ld = NVR.getLogin();
- var zm_cgi = data.toLowerCase();
-
- var user_cgi = (ld.streamingurl).toLowerCase();
- NVR.log("ZM relative cgi-path: " + zm_cgi + ", you entered: " + user_cgi);
-
- $http.get(ld.streamingurl + "/zms")
- .then(function (data) {
- data = data.data;
- NVR.debug("Urk! cgi-path returned success, but it should not have come here");
- loginStatus = $translate.instant('kLoginStatusNoCgi');
-
- NVR.debug("refreshing API version...");
- NVR.getAPIversion()
- .then(function (data) {
- var refresh = NVR.getMonitors(1);
- $rootScope.apiVersion = data;
- },
- function (error) {
- var refresh = NVR.getMonitors(1);
- $rootScope.apiVersion = "0.0.0";
- NVR.debug("Error, failed API version, setting to " + $rootScope.apiVersion);
- });
-
- if (showalert) {
- $rootScope.zmPopup = SecuredPopups.show('alert', {
- title: $translate.instant('kLoginValidatedTitle'),
- template: loginStatus,
- okText: $translate.instant('kButtonOk'),
- cancelText: $translate.instant('kButtonCancel'),
- }).then(function (res) {
-
- $ionicSideMenuDelegate.toggleLeft();
- NVR.debug("Force reloading monitors...");
-
- });
- }
- },
- function (error, status) {
- // If its 5xx, then the cgi-bin path is valid
- // if its 4xx then the cgi-bin path is not valid
-
- if (status < 500) {
- loginStatus = $translate.instant('kLoginStatusNoCgiAlt');
- }
-
- if (showalert) {
- $rootScope.zmPopup = SecuredPopups.show('alert', {
- title: $translate.instant('kLoginValidatedTitle'),
- template: loginStatus,
- okText: $translate.instant('kButtonOk'),
- cancelText: $translate.instant('kButtonCancel'),
- }).then(function (res) {
-
- $ionicSideMenuDelegate.toggleLeft();
- NVR.debug("Force reloading monitors...");
-
- });
- } else // make sure CGI error is always shown
- {
- NVR.displayBanner((status < 500) ? 'error' : 'info', [loginStatus]);
- }
- NVR.debug("refreshing API version...");
- NVR.getAPIversion()
- .then(function (data) {
- var refresh = NVR.getMonitors(1);
- $rootScope.apiVersion = data;
- },
- function (error) {
- var refresh = NVR.getMonitors(1);
- $rootScope.apiVersion = "0.0.0";
- NVR.debug("Error, failed API version, setting to " + $rootScope.apiVersion);
- });
+ var refresh = NVR.getMonitors(1);
+ $rootScope.apiVersion = data;
+ // console.log ("ALERT="+showalert);
+ if (showalert) {
+ $rootScope.zmPopup = SecuredPopups.show('alert', {
+ title: $translate.instant('kLoginValidatedTitle'),
+ template: loginStatus,
+ okText: $translate.instant('kButtonOk'),
+ cancelText: $translate.instant('kButtonCancel'),
+ }).then(function (res) {
+
+ $ionicSideMenuDelegate.toggleLeft();
+ NVR.debug("Force reloading monitors...");
});
- });
+ }
+
+ },
+ function (error) {
+ var refresh = NVR.getMonitors(1);
+ $rootScope.apiVersion = "0.0.0";
+ NVR.debug("Error, failed API version, setting to " + $rootScope.apiVersion);
+ });
},
function (error) {