diff options
| -rw-r--r-- | www/index.html | 2 | ||||
| -rw-r--r-- | www/js/DataModel.js | 1 | ||||
| -rw-r--r-- | www/js/LoginCtrl.js | 2 | ||||
| -rw-r--r-- | www/js/PortalLoginCtrl.js | 50 | ||||
| -rw-r--r-- | www/js/app.js | 23 |
5 files changed, 70 insertions, 8 deletions
diff --git a/www/index.html b/www/index.html index a23babaf..f7ca0c7a 100644 --- a/www/index.html +++ b/www/index.html @@ -45,6 +45,7 @@ <!-- cordova script (this will be a 404 during development) --> <script src="cordova.js"></script> <script src="js/ionicUtils.js"></script> + @@ -106,7 +107,6 @@ <script src="external/canvas-toBlob.js"></script> - </head> diff --git a/www/js/DataModel.js b/www/js/DataModel.js index 6d2bd45a..ebd95b10 100644 --- a/www/js/DataModel.js +++ b/www/js/DataModel.js @@ -430,6 +430,7 @@ angular.module('zmApp.controllers') isReCaptcha: function() { var d=$q.defer(); + var myurl =loginData.url; zmLog ("Checking if reCaptcha is enabled in ZM..."); $http.get(myurl) diff --git a/www/js/LoginCtrl.js b/www/js/LoginCtrl.js index 7a58b43f..b72e00cb 100644 --- a/www/js/LoginCtrl.js +++ b/www/js/LoginCtrl.js @@ -388,7 +388,7 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r - zmAutoLogin.doLogin("authenticating...") + zmAutoLogin.doLogin("<button class='button button-clear' style='line-height: normal; min-height: 0; min-width: 0;' ng-click='$root.cancelAuth()'><i class='ion-close-circled'></i></button>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 diff --git a/www/js/PortalLoginCtrl.js b/www/js/PortalLoginCtrl.js index 60782dcf..61367742 100644 --- a/www/js/PortalLoginCtrl.js +++ b/www/js/PortalLoginCtrl.js @@ -69,7 +69,7 @@ angular.module('zmApp.controllers').controller('zmApp.PortalLoginCtrl', ['$ionic $rootScope.rand = Math.floor((Math.random() * 100000) + 1); zmAutoLogin.stop(); //safety zmAutoLogin.start(); - zmAutoLogin.doLogin("authenticating...") + zmAutoLogin.doLogin("<button class='button button-clear' style='line-height: normal; min-height: 0; min-width: 0;' ng-click='$root.cancelAuth()'><i class='ion-close-circled'></i></button>authenticating...") .then(function (data) // success { ZMDataModel.zmDebug("PortalLogin: auth success"); @@ -120,7 +120,19 @@ angular.module('zmApp.controllers').controller('zmApp.PortalLoginCtrl', ['$ionic function (error) { ZMDataModel.zmDebug("PortalLogin: error authenticating " + JSON.stringify(error)); - $state.go('login'); + if (!$rootScope.userCancelledAuth) + { + $ionicHistory.nextViewOptions({ + disableAnimate: true, + disableBack: true + }); + $state.go('login'); + } + else + { + // do this only once - rest for next time + $rootScope.userCancelledAuth = false; + } }); } @@ -129,11 +141,27 @@ angular.module('zmApp.controllers').controller('zmApp.PortalLoginCtrl', ['$ionic if (ZMDataModel.isFirstUse()) { ZMDataModel.zmDebug ("First use, showing warm and fuzzy..."); + $ionicHistory.nextViewOptions({ + disableAnimate: true, + disableBack: true + }); $state.go('first-use'); } else { - $state.go('login'); + if (!$rootScope.userCancelledAuth) + { + $ionicHistory.nextViewOptions({ + disableAnimate: true, + disableBack: true + }); + $state.go('login'); + } + else + { + // do this only once - rest for next time + $rootScope.userCancelledAuth = false; + } } } @@ -186,7 +214,7 @@ angular.module('zmApp.controllers').controller('zmApp.PortalLoginCtrl', ['$ionic $rootScope.rand = Math.floor((Math.random() * 100000) + 1); zmAutoLogin.stop(); //safety zmAutoLogin.start(); - zmAutoLogin.doLogin("authenticating...") + zmAutoLogin.doLogin("<button class='button button-clear' style='line-height: normal; min-height: 0; min-width: 0;' ng-click='$root.cancelAuth()'><i class='ion-close-circled'></i></button>authenticating...") .then(function (data) // success { EventServer.refresh(); @@ -232,7 +260,19 @@ angular.module('zmApp.controllers').controller('zmApp.PortalLoginCtrl', ['$ionic function (error) { ZMDataModel.zmDebug("PortalLogin: error authenticating " + JSON.stringify(error)); - $state.go('login'); + if (!$rootScope.userCancelledAuth) + { + $ionicHistory.nextViewOptions({ + disableAnimate: true, + disableBack: true + }); + $state.go('login'); + } + else + { + // do this only once - rest for next time + $rootScope.userCancelledAuth = false; + } }); } else { $scope.pindata.status = "Invalid PIN"; diff --git a/www/js/app.js b/www/js/app.js index ab2d5f90..5b536932 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -89,6 +89,7 @@ angular.module('zmApp', [ }) + //------------------------------------------------------------------ // I use this factory to share data between carousel and lazy load // carousel will not progress autoslide till imageLoading is 0 or -1 @@ -591,7 +592,7 @@ angular.module('zmApp', [ //==================================================================== -.run(function ($ionicPlatform, $ionicPopup, $rootScope, zm, $state, $stateParams, ZMDataModel, $cordovaSplashscreen, $http, $interval, zmAutoLogin, zmCheckUpdates, $fileLogger, $timeout, $ionicHistory, $window, $ionicSideMenuDelegate, EventServer,$ionicContentBanner) { +.run(function ($ionicPlatform, $ionicPopup, $rootScope, zm, $state, $stateParams, ZMDataModel, $cordovaSplashscreen, $http, $interval, zmAutoLogin, zmCheckUpdates, $fileLogger, $timeout, $ionicHistory, $window, $ionicSideMenuDelegate, EventServer,$ionicContentBanner, $ionicLoading) { @@ -612,6 +613,7 @@ angular.module('zmApp', [ $rootScope.currentServerGroup = "defaultServer"; $rootScope.validMonitorId = ""; $rootScope.newVersionAvailable = ""; + $rootScope.userCancelledAuth = false; //$rootScope.minAlarmCount = "1"; @@ -650,6 +652,22 @@ angular.module('zmApp', [ window.addEventListener("resize", checkOrientation, false); + + // we come here when a user forcibly cancels portal auth + // useful when you know your auth won't succeed and you need to + // switch to another server + $rootScope.cancelAuth = function() + { + $ionicLoading.hide(); + ZMDataModel.zmLog("User cancelled login"); + $ionicHistory.nextViewOptions({ + disableAnimate: true, + disableBack: true + }); + $state.go("login"); + $rootScope.userCancelledAuth = true; + }; + //--------------------------------------------------------------------------- // authorize state transitions //---------------------------------------------------------------------------- @@ -694,6 +712,9 @@ angular.module('zmApp', [ $ionicPlatform.ready(function () { $rootScope.platformOS = "desktop"; + + + ZMDataModel.zmLog("Device is ready"); var ld = ZMDataModel.getLogin(); |
