diff options
Diffstat (limited to 'www/js')
| -rw-r--r-- | www/js/DataModel.js | 75 | ||||
| -rw-r--r-- | www/js/PortalLoginCtrl.js | 75 | ||||
| -rw-r--r-- | www/js/app.js | 22 |
3 files changed, 74 insertions, 98 deletions
diff --git a/www/js/DataModel.js b/www/js/DataModel.js index ab1ce647..85a29471 100644 --- a/www/js/DataModel.js +++ b/www/js/DataModel.js @@ -41,6 +41,7 @@ angular.module('zmApp.controllers').service('ZMDataModel', 'ZM_EVENT_IMAGE_DIGITS':'-1' }; + //-------------------------------------------------------------------------- // uses fileLogger to write logs to file for later investigation //-------------------------------------------------------------------------- @@ -382,79 +383,7 @@ angular.module('zmApp.controllers').service('ZMDataModel', // Grabs the computed auth key for streaming // FIXME: Currently a hack - does a screen parse - convert to API based support //----------------------------------------------------------------------------- - validatePin: function() - { - - var d=$q.defer(); - if (loginData.usePin) - { - zmDebug("Validating PIN..."); - var pinMatch = false; - - //<input type="number" pattern="[0-9]*"> - $rootScope.pindata={}; - var pinPrompt = $ionicPopup.show({ - template: '<input type="number" pattern="[0-9]*" ng-model="$root.pindata.pin">', - title: 'PIN validation', - subtitle: 'Please confirm your PIN', - scope: $rootScope, - buttons: [ - { - text: 'Ok', - type:'button-positive', - onTap: function(e) - { - if ($rootScope.pindata.pin != loginData.pinCode) - { - displayBanner("error",["Invalid PIN. Please try again"]); - zmLog("Invalid PIN entered "); - e.preventDefault(); - $rootScope.pindata.pin=""; - } - else - { - zmLog("PIN was correct"); - d.resolve(true); - } - - } - }, - ]}); - return (d.promise); - /*$cordovaPinDialog.prompt ('Enter PIN', 'PIN Confirm', ["OK"]) - .then( function (result) - { - if (result.input1 != loginData.pinCode) - { - displayBanner("error",["Invalid PIN. Please try again"]); - zmLog("Invalid PIN entered, looping..."); - d.resolve(false); - } - else - { - pinMatch = true; - zmLog("Valid PIN entered"); - d.resolve(true); - } - }, - - function (error) - { - zmLog("PIN error handler. Should not come here"); - d.resolve(false); - });*/ - - - - } - else - { - zmDebug("No PIN set, skipping"); - d.resolve(true); - return (d.promise); - - } - }, + getAuthKey: function () { diff --git a/www/js/PortalLoginCtrl.js b/www/js/PortalLoginCtrl.js index 97da4e2c..11f7543b 100644 --- a/www/js/PortalLoginCtrl.js +++ b/www/js/PortalLoginCtrl.js @@ -12,17 +12,74 @@ angular.module('zmApp.controllers').controller('zmApp.PortalLoginCtrl', ['$ionic disableBack: true }); + $scope.pindata = {}; + if ($ionicSideMenuDelegate.isOpen()) + { + $ionicSideMenuDelegate.toggleLeft(); + ZMDataModel.zmDebug("Sliding menu close"); + } + + $scope.pinChange = function() + { + + console.log ($scope.pindata.pin); + if ($scope.pindata.pin == null) + { + console.log ("Empty"); + $scope.pindata.status=""; + } + }; + + $scope.unlock = function() + { + ZMDataModel.zmDebug("Trying to unlock PIN"); + if ($scope.pindata.pin == loginData.pinCode) + { + ZMDataModel.zmDebug ("PIN code entered is correct"); + $rootScope.rand = Math.floor((Math.random() * 100000) + 1); + zmAutoLogin.stop(); //safety + zmAutoLogin.start(); + zmAutoLogin.doLogin("authenticating...") + .then (function(data) // success + { + ZMDataModel.zmDebug("PortalLogin: auth success"); + ZMDataModel.getKeyConfigParams(1); + $state.go('montage'); + }, + // coming here means auth error + // so go back to login + function (error) + { + ZMDataModel.zmDebug("PortalLogin: error authenticating " + + JSON.stringify(error)); + $state.go('login'); + }); + } + else + { + $scope.pindata.status = "Invalid PIN"; + } + }; + var loginData = ZMDataModel.getLogin(); + $scope.pinPrompt = false; if (ZMDataModel.isLoggedIn()) { ZMDataModel.zmLog ("User credentials are provided"); - ZMDataModel.validatePin() - .then( function (data) { - - // console.log("VALID CREDENTIALS. Grabbing Monitors"); - ZMDataModel.zmDebug("PortalLogin: Authenticating"); - zmAutoLogin.doLogin("authenticating...") + if (loginData.usePin) + { + $scope.pinPrompt = true; + + + } + else{ + + ZMDataModel.zmDebug ("PIN code not set"); + $rootScope.rand = Math.floor((Math.random() * 100000) + 1); + zmAutoLogin.stop(); //safety + zmAutoLogin.start(); + zmAutoLogin.doLogin("authenticating...") .then (function(data) // success { ZMDataModel.zmDebug("PortalLogin: auth success"); @@ -37,7 +94,11 @@ angular.module('zmApp.controllers').controller('zmApp.PortalLoginCtrl', ['$ionic JSON.stringify(error)); $state.go('login'); }); - }); + + + } + + } else { diff --git a/www/js/app.js b/www/js/app.js index 214e4f2d..045b4501 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -615,32 +615,18 @@ angular.module('zmApp', [ // from foreground to background and back document.addEventListener("resume", function () { ZMDataModel.zmLog("App is resuming from background"); + $state.go("zm-portal-login"); - $ionicSideMenuDelegate.toggleLeft(false); - ZMDataModel.validatePin() - .then ( function(data) - { - $rootScope.rand = Math.floor((Math.random() * 100000) + 1); - //$scope.rand = Math.floor((Math.random() * 100000) + 1); - console.log("** generated Random of " + $rootScope.rand); - zmAutoLogin.stop(); //safety - zmAutoLogin.start(); - zmAutoLogin.doLogin("authenticating ..."); - - }); - + //$ionicSideMenuDelegate.toggleLeft(false); + //ZMDataModel.validatePin() - - - - - }, false); document.addEventListener("pause", function () { console.log("****The application is going into background"); ZMDataModel.zmLog("App is going into background"); + zmAutoLogin.stop(); }, false); |
