New PIN page

This commit is contained in:
Gustavo Maximiliano Cortez 2015-01-29 01:56:32 -03:00
parent 77f8faaae6
commit 36bd87f729
9 changed files with 236 additions and 187 deletions

View File

@ -1655,7 +1655,7 @@ input.ng-invalid-match, input.ng-invalid-match:focus {
}
.clipo {
padding: 0 0 2rem;
margin-bottom: 2rem;
text-align: center;
}

View File

@ -4,7 +4,32 @@
*
*/
@media (max-width: 1024px) {
@media (max-width: 1024px) {
/* disabling text selection */
* {
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
input {
-webkit-user-select: auto !important;
-khtml-user-select: auto !important;
-moz-user-select: auto !important;
-ms-user-select: auto !important;
user-select: auto !important;
}
* {
-webkit-user-drag: none;
-moz-user-drag: none;
-ms-user-drag: none;
user-drag: none;
}
/* END disabling text selection */
.inner-wrap {
-webkit-transition-duration: 250ms;
@ -14,7 +39,7 @@
body {
overflow: hidden;
-ms-content-zooming: none;
}
}
.loading-screen {
background-color: #2C3E50;
@ -363,6 +388,45 @@
/*******************************************/
.pin {
margin: 0 auto;
width: 70%;
text-align: center;
overflow: hidden;
}
.pin-box {
color: #fff;
font-size: 28px;
width: 25%;
float: left;
}
.pin-numbers {
position: absolute;
bottom: 0;
width: 100%;
text-align: center;
background-color: #000;
height: 50%;
}
.pin-button-bar {
height: 25%;
}
a.pin-button {
margin: 2px;
padding: 4% 10%;
display: inline-block;
color: #ccc;
font-size: 120%;
}
a.pin-button:active {
color: #fff;
}
}
@media (max-width: 640px) {

View File

@ -2,7 +2,7 @@
angular.module('copayApp.controllers').controller('CreateProfileController', function($scope, $rootScope, $location, $timeout, $window, notification, pluginManager, identityService, pinService, isMobile, isCordova, configService, go) {
var _credentials, _firstpin;
var _credentials;
$scope.init = function() {
@ -12,41 +12,27 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun
$scope.isMobile = isMobile.any();
$scope.isWindowsPhoneApp = isMobile.Windows() && isCordova;
$scope.hideForWP = 0;
$scope.digits = [];
$scope.defined = [];
$rootScope.askForPin = 0;
$scope.createStep = 'storage';
$scope.useLocalstorage = false;
$scope.minPasswordStrength = _.isUndefined(config.minPasswordStrength) ?
4 : config.minPasswordStrength;
};
pinService.makePinInput($scope, 'newpin', function(newValue) {
_firstpin = newValue;
$scope.hideForWP = 0;
$scope.askForPin = 2;
$timeout(function() {
$scope.$digest();
}, 1);
$scope.clear = function() {
pinService.clearPin($scope);
};
$scope.press = function(digit) {
pinService.pressPin($scope, digit, true);
};
});
pinService.makePinInput($scope, 'repeatpin', function(newValue) {
if (newValue === _firstpin) {
_firstpin = null;
$scope.createPin(newValue);
} else {
$scope.askForPin = 1;
$scope.hideForWP = 0;
$scope.passwordStrength = null;
_firstpin = null;
$scope.error = 'Entered PINs were not equal. Try again';
$timeout(function() {
$scope.$digest();
}, 1);
}
});
$scope.skip = function () {
pinService.skipPin($scope, true);
};
$scope.formFocus = function() {
@ -63,14 +49,11 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun
preconditions.checkState(_credentials && _credentials.email);
$rootScope.starting = true;
// hide Keyboard after submit form
$window.document.querySelector('#repeatpin').blur();
$timeout(function() {
pinService.save(pin, _credentials.email, _credentials.password, function(err) {
_credentials.password = '';
_credentials = null;
$scope.askForPin = 0;
$rootScope.askForPin = 0;
$rootScope.hasPin = true;
$scope.createDefaultWallet();
});
@ -117,7 +100,7 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun
$rootScope.hideNavigation = false;
$rootScope.starting = true;
identityService.createDefaultWallet(function(err) {
$scope.askForPin = 0;
$rootScope.askForPin = 0;
$rootScope.starting = null;
if (err) {
@ -157,7 +140,7 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun
email: emailOrUsername,
password: password,
};
$scope.askForPin = 1;
$rootScope.askForPin = 1;
$scope.hideForWP = 0;
$rootScope.hideNavigation = true;

View File

@ -1,15 +1,19 @@
'use strict';
angular.module('copayApp.controllers').controller('HomeController', function($scope, $rootScope, $timeout, $window, go, notification, identityService, Compatibility, pinService, applicationService, isMobile, isCordova, localstorageService) {
angular.module('copayApp.controllers').controller('HomeController', function($scope, $rootScope, $timeout, $window, go, notification, identityService, Compatibility, pinService, applicationService, isMobile, isCordova, localstorageService) {
var KEY = 'CopayDisclaimer';
var ls = localstorageService;
var _credentials, _firstpin;
var _credentials;
$scope.init = function() {
$scope.isMobile = isMobile.any();
$scope.isWindowsPhoneApp = isMobile.Windows() && isCordova;
$scope.hideForWP = 0;
$scope.attempt = 0;
$scope.attempt = 0;
$scope.digits = [];
$scope.defined = [];
$rootScope.askForPin = 0;
// This is only for backwards compat, insight api should link to #!/confirmed directly
if (getParam('confirmed')) {
@ -40,6 +44,18 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc
}
};
$scope.clear = function() {
pinService.clearPin($scope);
};
$scope.press = function(digit) {
pinService.pressPin($scope, digit);
};
$scope.skip = function () {
pinService.skipPin($scope);
};
$scope.agreeDisclaimer = function() {
ls.setItem(KEY, true, function(err) {
$scope.showDisclaimer = null;
@ -55,31 +71,6 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc
}
};
pinService.makePinInput($scope, 'pin', function(newValue) {
$scope.openWithPin(newValue);
});
pinService.makePinInput($scope, 'newpin', function(newValue) {
_firstpin = newValue;
$scope.askForPin = 2;
});
pinService.makePinInput($scope, 'repeatpin', function(newValue) {
if (newValue === _firstpin) {
_firstpin = null;
$scope.createPin(newValue);
} else {
$scope.$$childTail.setPinForm.newpin.$setViewValue('');
$scope.$$childTail.setPinForm.newpin.$render();
$scope.$$childTail.setPinForm.repeatpin.$setViewValue('');
$scope.$$childTail.setPinForm.repeatpin.$render();
_firstpin = null;
$scope.askForPin = 1;
$scope.error = 'Entered PINs were not equal. Try again';
}
});
$scope.openWithPin = function(pin) {
if (!pin) {
@ -88,14 +79,15 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc
}
$rootScope.starting = true;
// hide Keyboard after submit form
$window.document.querySelector('#pin').blur();
$timeout(function() {
var credentials = pinService.get(pin, function(err, credentials) {
if (err || !credentials) {
$rootScope.starting = null;
$scope.error = 'Wrong PIN';
$scope.clear();
$timeout(function() {
$scope.error = null;
}, 2000);
return;
}
$scope.open(credentials.email, credentials.password);
@ -117,14 +109,11 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc
preconditions.checkState(_credentials && _credentials.email);
$rootScope.starting = true;
// hide Keyboard after submit form
$window.document.querySelector('#repeatpin').blur();
$timeout(function() {
pinService.save(pin, _credentials.email, _credentials.password, function(err) {
_credentials.password = '';
_credentials = null;
$scope.askForPin = 0;
$rootScope.askForPin = 0;
$rootScope.hasPin = true;
$rootScope.starting = null;
$scope.openWallets();
@ -194,7 +183,7 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc
email: email,
password: password,
};
$scope.askForPin = 1;
$rootScope.askForPin = 1;
$rootScope.starting = false;
$rootScope.hideNavigation = true;
$timeout(function() {

View File

@ -10,6 +10,8 @@ angular.module('copayApp.services')
var ls = localstorageService;
var root = {};
var _firstpin;
root.check = function(cb) {
ls.getItem(KEY, function(err, value) {
return cb(err, value ? true : false);
@ -48,27 +50,61 @@ angular.module('copayApp.services')
ls.removeItem(KEY, cb);
};
root.makePinInput = function(scope, name, cb) {
Object.defineProperty(scope, name, {
get: function() {
return this['_' + name];
},
set: function(newValue) {
this['_' + name] = newValue;
scope.error = null;
scope.loading = null;
if (newValue && newValue.length == 4) {
$timeout(function() {
return cb(newValue);
}, 30);
}
},
enumerable: true,
configurable: true
});
root.clearPin = function(scope) {
scope.digits = [];
scope.defined = [];
};
root.pressPin = function(scope, digit, skipOpenWithPin) {
scope.error = null;
scope.digits.push(digit);
scope.defined.push(true);
if (scope.digits.length == 4) {
var pin = scope.digits.join('');
if (!$rootScope.hasPin) {
if (!_firstpin) {
_firstpin = pin;
$timeout(function() {
scope.clear();
}, 100);
return;
}
else {
if (pin === _firstpin) {
scope.createPin(pin);
}
else {
_firstpin = null;
$timeout(function() {
scope.clear();
scope.error = 'Entered PINs were not equal. Try again';
$timeout(function() {
scope.error = null;
}, 2000);
}, 100);
return;
}
}
}
if (!skipOpenWithPin) {
scope.openWithPin(pin);
}
}
};
root.skipPin = function(scope, creatingProfile) {
if (!$rootScope.hasPin) {
if (!creatingProfile) {
scope.openWallets();
}
else {
scope.createDefaultWallet()
}
}
else {
scope.pinLogout();
}
};
return root;
});

View File

@ -1,9 +1,15 @@
<div class="createProfile" ng-controller="CreateProfileController" ng-init="init()">
<div ng-if="!$root.starting && $root.askForPin">
<div ng-include="'views/includes/pin-number.html'"></div>
</div>
<div ng-show="$root.starting">
<div ng-include="'views/includes/loading.html'" ng-init="title = 'Creating profile'"></div>
</div>
<div class="large-4 large-centered medium-7 medium-centered columns m20b" ng-show="!$root.starting && !askForPin">
<div class="row m20b" ng-show="!$root.starting && !$root.askForPin">
<div class="large-4 large-centered medium-7 medium-centered columns">
<div class="logo-setup hide-for-small-only" ng-hide="hideForWP">
<img src="img/logo-negative-beta.svg" alt="Copay" width="100">
</div>
@ -199,13 +205,15 @@
</div>
</div>
</div>
<div class="large-4 large-centered medium-6 medium-centered columns m20b" ng-show="!$root.starting && askForPin">
<div class="clipo" ng-hide="hideForWP">
<div class="row m20b" ng-show="!$root.starting && $root.askForPin">
<div class="large-4 large-centered medium-6 medium-centered columns">
<div class="clipo">
<img src="img/clipo-pin.png" alt="clipo" width="380">
</div>
<div class="box-notification" ng-show="error && !passwordStrength">
<div class="box-notification" ng-show="error">
<div class="box-icon error">
<i class="fi-x size-24"></i>
</div>
@ -213,30 +221,8 @@
{{error|translate}}
</span>
</div>
<form name="setPinForm" ng-model="setPinForm" novalidate>
<div class="input" ng-if="askForPin == 1">
<input id="newpin" type="tel" ng-model="newpin" class="form-control" ng-maxlength="4" ng-minlength="4" maxlength="4" ng-pattern="/^[0-9]{1,4}$/" placeholder="PIN" name="newpin" required show-focus="askForPin == 1 && !isWindowsPhoneApp" ng-focus="formFocus()">
<i class="icon-locked" ng-hide="isWindowsPhoneApp"></i>
</div>
<div class="input" ng-if="askForPin == 2">
<input id="repeatpin" type="tel" ng-model="repeatpin" class="form-control" ng-maxlength="4" ng-minlength="4" maxlength="4" ng-pattern="/^[0-9]{1,4}$/" placeholder="Confirm your PIN" name="repeatpin" required show-focus="askForPin == 2 && !isWindowsPhoneApp" ng-focus="formFocus()">
<i class="icon-locked"></i>
</div>
<div class="box-setup-footer row collapse">
<div class="large-6 medium-6 small-6 columns">
<a class="button secondary radius m0" ng-click="createDefaultWallet()">
<span translate>Skip</span>
</a>
</div>
<div class="large-6 medium-6 small-6 columns text-right">
<button translate ng-click="createPin(setPinForm.repeatpin.$modelValue)" class="button primary radius expand m0"
ng-disabled="setPinForm.$invalid || error">
OK
</button>
</div>
</div>
</form>
<div ng-include="'views/includes/pin.html'"></div>
</div>
</div>
</div>

View File

@ -1,5 +1,10 @@
<div class="home" ng-controller="HomeController" ng-init="init()">
<div ng-if="$root.askForPin || ($root.hasPin && !$root.iden)">
<div ng-include="'views/includes/pin-number.html'"></div>
</div>
<div ng-show="$root.starting">
<div ng-include="'views/includes/loading.html'" ng-init="title = 'Accessing your profile'"></div>
</div>
@ -33,9 +38,10 @@
</div>
</div>
<div class="row">
<div class="large-4 large-centered medium-6 medium-centered columns" ng-show="!$root.starting && !showDisclaimer">
<div class="logo-setup" ng-show="!$root.iden && !hideForWP">
<div class="logo-setup" ng-show="!$root.iden && !hideForWP && !$root.hasPin">
<img src="img/logo-negative-beta.svg" alt="Copay" width="100">
<div ng-include="'views/includes/version.html'"></div>
</div>
@ -52,11 +58,11 @@
</div>
</div>
<div ng-if="askForPin">
<div ng-if='$root.askForPin || ($root.hasPin && !$root.iden)'>
<div class="clipo">
<img src="img/clipo-pin.png" alt="clipo" width="380">
<img src="img/clipo-pin-enter.png" alt="clipo" width="300" ng-show="$root.hasPin && !$root.iden">
<img src="img/clipo-pin.png" alt="clipo" width="380" ng-show="$root.askForPin">
</div>
<div class="box-notification" ng-show="error">
<div class="box-icon error">
<i class="fi-x size-24"></i>
@ -65,72 +71,10 @@
{{error|translate}}
</span>
</div>
<form name="setPinForm" ng-model="setPinForm" novalidate>
<div class="input" ng-show="askForPin == 1">
<input id="newpin" type="tel" ng-model="newpin" class="form-control" ng-maxlength="4" ng-minlength="4" maxlength="4" ng-pattern="/^[0-9]{1,4}$/" placeholder="PIN" name="newpin" required show-focus="askForPin == 1 && !isWindowsPhoneApp" ng-focus="formFocus()">
<i class="icon-locked"></i>
</div>
<div class="input" ng-show="askForPin == 2">
<input id="repeatpin" type="tel" ng-model="repeatpin" class="form-control" ng-maxlength="4" ng-minlength="4" maxlength="4" ng-pattern="/^[0-9]{1,4}$/" placeholder="Confirm your PIN" name="repeatpin" required show-focus="askForPin == 2 && !isWindowsPhoneApp" ng-focus="formFocus()">
<i class="icon-locked"></i>
</div>
<div class="row collapse">
<div class="large-6 medium-6 small-6 columns">
<a class="button secondary radius m0" ng-click="openWallets()">
<span translate>Skip</span>
</a>
</div>
<div class="large-6 medium-6 small-6 columns text-right">
<button translate ng-click="createPin(setPinForm.repeatpin.$modelValue)" class="button primary radius expand m0"
ng-disabled="setPinForm.$invalid || error">
OK
</button>
</div>
</div>
</form>
<div ng-include="'views/includes/pin.html'"></div>
</div>
<div ng-if='$root.hasPin && !$root.iden'>
<div class="clipo" ng-hide="hideForWP">
<img src="img/clipo-pin-enter.png" alt="clipo" width="300">
</div>
<form name="pinForm" novalidate>
<div class="box-notification" ng-show="error">
<div class="box-icon error">
<i class="fi-x size-24"></i>
</div>
<span class="text-warning size-14">
{{error|translate}}
</span>
</div>
<div class="input">
<input id="pin" type="tel" ng-model="pin" class="form-control" ng-maxlength="4" ng-minlength="4" maxlength="4" ng-pattern="/^[0-9]{1,4}$/" placeholder="Pin number" name="pin" required ng-focus="formFocus()">
<i class="icon-locked"></i>
</div>
<div class="row collapse">
<div class="large-6 medium-6 small-6 columns">
<a class="button warning radius m0" ng-click="pinLogout()">
<i class="icon-power"></i>
<span translate>Logout</span>
</a>
</div>
<div class="large-6 medium-6 small-6 columns text-right">
<button translate ng-click="openWithPin(pinForm.pin.$modelValue)" class="button primary radius expand m0"
ng-disabled="pinForm.$invalid || error">
Sign in
</button>
</div>
</div>
</form>
</div>
<div ng-if='!$root.hasPin && !askForPin && !$root.iden'>
<div ng-if='!$root.hasPin && !$root.askForPin && !$root.iden'>
<div class="clipo" ng-hide="hideForWP">
<img src="img/clipo-signin.png" alt="clipo" width="310">
</div>
@ -213,6 +157,7 @@ aasdas
</div>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,25 @@
<div class="pin-numbers">
<div class="pin-button-bar">
<a class="pin-button" ng-click="press(1)">1</a>
<a class="pin-button" ng-click="press(2)">2</a>
<a class="pin-button" ng-click="press(3)">3</a>
</div>
<div class="pin-button-bar">
<a class="pin-button" ng-click="press(4)">4</a>
<a class="pin-button" ng-click="press(5)">5</a>
<a class="pin-button" ng-click="press(6)">6</a>
</div>
<div class="pin-button-bar">
<a class="pin-button" ng-click="press(7)">7</a>
<a class="pin-button" ng-click="press(8)">8</a>
<a class="pin-button" ng-click="press(9)">9</a>
</div>
<div class="pin-button-bar">
<a class="pin-button" ng-click="skip()">
<i class="fi-unlock" ng-show="$root.hasPin"></i>
<i class="fi-home" ng-show="!$root.hasPin"></i>
</a>
<a class="pin-button" ng-click="press(0)">0</a>
<a class="pin-button" ng-click="clear()"><i class="fi-arrow-left"></i></a>
</div>
</div>

21
views/includes/pin.html Normal file
View File

@ -0,0 +1,21 @@
<div class="pin" ng-show="!error">
<div class="pin-box">
<i class="" ng-show="!defined[0]">-</i>
<i class="" ng-show="defined[0]">*</i>
</div>
<div class="pin-box">
<i class="" ng-show="!defined[1]">-</i>
<i class="" ng-show="defined[1]">*</i>
</div>
<div class="pin-box">
<i class="" ng-show="!defined[2]">-</i>
<i class="" ng-show="defined[2]">*</i>
</div>
<div class="pin-box">
<i class="" ng-show="!defined[3]">-</i>
<i class="" ng-show="defined[3]">*</i>
</div>
</div>