diff options
| author | = <=> | 2019-03-14 14:22:29 -0400 |
|---|---|---|
| committer | = <=> | 2019-03-14 14:22:29 -0400 |
| commit | 7cb24d55f47dc28d91710d5c22cfc30a0a59b583 (patch) | |
| tree | dcca268fc1c95ae4233951e928a370992647f5a8 | |
| parent | 9e1e17a259fc206a70cb4bf6c8142059510003f2 (diff) | |
#784 well what the heck, password for desktops
| -rw-r--r-- | www/js/LoginCtrl.js | 65 | ||||
| -rw-r--r-- | www/js/PortalLoginCtrl.js | 52 | ||||
| -rw-r--r-- | www/templates/login.html | 4 |
3 files changed, 115 insertions, 6 deletions
diff --git a/www/js/LoginCtrl.js b/www/js/LoginCtrl.js index 44f69d04..fef2c1ce 100644 --- a/www/js/LoginCtrl.js +++ b/www/js/LoginCtrl.js @@ -371,7 +371,72 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r // When PIN is enabled, this is called to specify a PIN // FIXME: Get rid of cordovaPinDialog. It's really not needed //-------------------------------------------------------------------------- + $scope.pinPrompt = function (evt) { + NVR.log ("use password:"+$scope.loginData.usePin); + + if (!$scope.loginData.usePin) { + return; + } + + if ($rootScope.platformOS == 'desktop') { + desktopPinConfig(); + } + else { + mobilePinConfig(); + } + } + + + function desktopPinConfig() { + + $scope.data = {}; + // An elaborate, custom popup + var myPopup = $ionicPopup.show({ + template: '<small>'+$translate.instant('kPinProtect')+'</small><input type="password" ng-model="data.p1"><br/><small>'+$translate.instant('kReconfirmPin')+'</small><input type="password" ng-model="data.p2">', + title: $translate.instant('kPinProtect'), + scope: $scope, + buttons: [ + { text: 'Cancel', + type: 'button-assertive', + onTap: function (e) { + $scope.loginData.usePin = false; + } + }, + { + text: '<b>Save</b>', + type: 'button-positive', + onTap: function(e) { + if (!$scope.data.p1) { + //don't allow the user to close unless he enters wifi password + e.preventDefault(); + } else { + if ($scope.data.p1 == $scope.data.p2) { + NVR.log ("Pin code match"); + $scope.loginData.pinCode = $scope.data.p1; + } + else { + $ionicLoading.show({ + template: $translate.instant('kBannerPinMismatch') + "...", + noBackdrop: true, + duration: 1500 + }); + NVR.log ("Pin code mistmatch match"); + $scope.loginData.usePin = false; + e.preventDefault(); + } + + } + } + } + ] + }); + + +} + + +function mobilePinConfig () { NVR.log("Password prompt"); if ($scope.loginData.usePin) { $scope.loginData.pinCode = ""; diff --git a/www/js/PortalLoginCtrl.js b/www/js/PortalLoginCtrl.js index 95967ed0..35572166 100644 --- a/www/js/PortalLoginCtrl.js +++ b/www/js/PortalLoginCtrl.js @@ -95,7 +95,49 @@ angular.module('zmApp.controllers').controller('zmApp.PortalLoginCtrl', ['$ionic NVR.setLogin(ld); unlock(true); - } else if ($ionicPlatform.is('android') && loginData.usePin) { + } + + else if ($rootScope.platformOS == 'desktop' && loginData.usePin) { + + $scope.passwdData = {}; + var myPopup = $ionicPopup.show({ + template: '<input type="password" ng-model="passwdData.pass">', + title: $translate.instant('kPinProtect'), + scope: $scope, + buttons: [ + + { + text: $translate.instant('kButtonOk'), + type: 'button-positive', + onTap: function(e) { + if (!$scope.passwdData.pass) { + //don't allow the user to close unless he enters wifi password + e.preventDefault(); + } else { + if ($scope.passwdData.pass == loginData.pinCode) { + NVR.log ("Pin code match"); + unlock(true); + } + else { + $ionicLoading.show({ + template: $translate.instant('kBannerPinMismatch') + "...", + noBackdrop: true, + duration: 1500 + }); + NVR.log ("Pin code mistmatch match"); + e.preventDefault(); + } + + } + } + } + ] + }); + + + + } + else if ($ionicPlatform.is('android') && loginData.usePin) { FingerprintAuth.isAvailable(function (result) { NVR.debug("FingerprintAuth available: " + JSON.stringify(result)); @@ -166,12 +208,14 @@ angular.module('zmApp.controllers').controller('zmApp.PortalLoginCtrl', ['$ionic NVR.log("not checking for touchID"); } - if (loginData.usePin) { + if (loginData.usePin ) { // this shows the pin prompt on screen - $scope.pinPrompt = true; + if ($rootScope.platformOS != 'desktop') { + $scope.pinPrompt = true; + } // dont call unlock, let the user type in code - } else // no PIN Code so go directly to auth + } else // no PIN Code so go directly to auth { unlock(true); diff --git a/www/templates/login.html b/www/templates/login.html index 5e823a56..32f1a683 100644 --- a/www/templates/login.html +++ b/www/templates/login.html @@ -97,13 +97,13 @@ <i class="icon ion-ios-arrow-right"> </i> {{'kEventServer' | translate}} </a> - <div ng-if="$root.platformOS != 'desktop'"> + <label> <ion-toggle ng-model="loginData.usePin" ng-change="pinPrompt();" toggle-class="toggle-calm"> <span class="item-text-wrap">{{'kPassword' | translate}} {{'kProtect'|translate}}</span> </ion-toggle> </label> - </div> + <div ng-if="$root.platformOS != 'desktop'"> <label> |
