summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPliablePixels <pliablepixels@gmail.com>2015-09-15 14:41:54 -0400
committerPliablePixels <pliablepixels@gmail.com>2015-09-15 14:41:54 -0400
commit2a7699ac57249422b09951cecf8f93c641634990 (patch)
treebf9a2baa7b9ce588a3c9cd2a96234df0cacbe55a
parent606d3b95e941f48c8963d3996920472145da1200 (diff)
Fixed the colossal crap that was PIN code auth. Still need to clean up rough edges but overall looks good now
-rw-r--r--www/css/style.css10
-rw-r--r--www/js/DataModel.js75
-rw-r--r--www/js/PortalLoginCtrl.js75
-rw-r--r--www/js/app.js22
-rw-r--r--www/templates/zm-portal-login.html23
5 files changed, 103 insertions, 102 deletions
diff --git a/www/css/style.css b/www/css/style.css
index 3255c156..58ab4b27 100644
--- a/www/css/style.css
+++ b/www/css/style.css
@@ -395,10 +395,18 @@ input[type=range]::-webkit-slider-thumb {
}
/* this is for input = password and dialog = text */
-input[type=number] {
+.pinCode input[type=number] {
-webkit-text-security: disc;
}
+
+.pinCode input[type=number]{
+ height: 50px;
+ width:200px;
+ text-align: center;
+ font-size: 2em;
+ border: 1px solid #000;
+}
/*.mySliderClass.jslider.sliderCSS div.jslider-pointer
{top:-10px;left:15px;width:60px;height:60px;margin-left:-5px;background-color:silver;background-color:#615959;border-radius:50%
}*/
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);
diff --git a/www/templates/zm-portal-login.html b/www/templates/zm-portal-login.html
index 56d2ee2e..e65504f7 100644
--- a/www/templates/zm-portal-login.html
+++ b/www/templates/zm-portal-login.html
@@ -1,4 +1,21 @@
-<ion-view view-title="" style="background-color:#444444">
- <ion-content style="background-color:#444444">
+<ion-view view-title="zmNinja" hide-back-button="true" cache-view="false">
+ <ion-content class="padding">
+
+ <div ng-if="pinPrompt">
+ <div style="margin-left:10px; margin-right:10px">
+ <center>
+ <h4>Enter PIN</h4>
+ <div class="pinCode">
+ <input type="number" pattern="[0-9]*" ng-model="pindata.pin" ng-keyup="pinChange()" />
+ </div>
+ <br/> {{pindata.status}}
+ <br/>
+ <button class="button button-block button-stable icon ion-unlocked" ng-click="unlock()"> Unlock
+ </button>
+ </center>
+ </div>
+
+ </div>
+
</ion-content>
- </ion-view> \ No newline at end of file
+</ion-view> \ No newline at end of file