diff options
| author | PliablePixels <pliablepixels@gmail.com> | 2015-08-11 15:47:11 -0400 |
|---|---|---|
| committer | PliablePixels <pliablepixels@gmail.com> | 2015-08-11 15:47:11 -0400 |
| commit | a09333e8b97a5f5c71331ce18777889510aed302 (patch) | |
| tree | 9f6b69e4996088ee13004c3bee6ea9d5f57e89db /www/js/LoginCtrl.js | |
| parent | 68af457b04b26e26f0414b821dabe7359e18a0ad (diff) | |
API auth tied into ZM auth, enabled client to work in both auth and non-auth mode honoring ZM's auth system
Diffstat (limited to 'www/js/LoginCtrl.js')
| -rw-r--r-- | www/js/LoginCtrl.js | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/www/js/LoginCtrl.js b/www/js/LoginCtrl.js index b3c052d5..082930be 100644 --- a/www/js/LoginCtrl.js +++ b/www/js/LoginCtrl.js @@ -8,7 +8,11 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r }; $scope.loginData = ZMDataModel.getLogin(); + + $scope.auth={isUseAuth:""}; + $scope.auth.isUseAuth = ($scope.loginData.isUseAuth == '1') ? true:false; + //------------------------------------------------------------------------- @@ -78,6 +82,8 @@ function addhttp(url) { $scope.loginData.apiurl = $scope.loginData.apiurl.trim(); $scope.loginData.username = $scope.loginData.username.trim(); $scope.loginData.streamingurl = $scope.loginData.streamingurl.trim(); + + $scope.loginData.isUseAuth = ($scope.auth.isUseAuth) ? "1": "0"; if ($scope.loginData.url.slice(-1) == '/') { $scope.loginData.url = $scope.loginData.url.slice(0, -1); @@ -122,10 +128,6 @@ function addhttp(url) { $scope.loginData.streamingurl = $scope.loginData.streamingurl.replace("https:","http:"); } - - - // FIXME:: Do a login id check too - var apiurl = $scope.loginData.apiurl + '/host/getVersion.json'; var portalurl = $scope.loginData.url + '/index.php'; var streamingurl = $scope.loginData.streamingurl + @@ -200,15 +202,31 @@ function addhttp(url) { } );*/ + + // Check if isUseAuth is set make sure u/p have a dummy value + if ($scope.isUseAuth) + { + if (!$scope.loginData.username) $scope.loginData.username="x"; + if (!$scope.loginData.password) $scope.loginData.password="x"; + ZMDataModel.zmLog("Authentication is disabled, setting dummy user & pass"); + } + ZMDataModel.setLogin($scope.loginData); - zmAutoLogin.doLogin("Logging into ZoneMinder") + zmAutoLogin.doLogin("authenticating...") + // Do the happy menu only if authentication works + // if it does not work, there is an emitter for auth + // fail in app.js that will be called to show an error + // box + + // Note that API auth ties into ZM Auth, so in one fell + // swoop we've just validated both. Happy? .then( function(data) { console.log ("THE DATA WAS " + data); console.log ("SHOWING POPUP "); $ionicPopup.alert({ - title: 'Settings Saved', + title: 'Login validated', template: 'Please explore the menu and enjoy zmNinja!' }).then(function(res) { $ionicSideMenuDelegate.toggleLeft();}); }); |
