adding verification option to passphrase on create personal wallet

This commit is contained in:
Gabriel Bazán 2017-05-22 15:36:38 -03:00
commit 511281af2a
3 changed files with 63 additions and 13 deletions

View file

@ -29,27 +29,41 @@ angular.module('copayApp.controllers').controller('createController',
$scope.formData.derivationPath = derivationPathHelper.default; $scope.formData.derivationPath = derivationPathHelper.default;
$scope.setTotalCopayers(tc); $scope.setTotalCopayers(tc);
updateRCSelect(tc); updateRCSelect(tc);
resetPasswordFields();
}; };
$scope.showAdvChange = function() { $scope.showAdvChange = function() {
$scope.showAdv = !$scope.showAdv; $scope.showAdv = !$scope.showAdv;
$scope.encrypt = null;
$scope.resizeView(); $scope.resizeView();
}; };
$scope.checkPassword = function(pw1, pw2) {
if (pw1 && pw1.length > 0) {
if (pw2 && pw2.length > 0) {
if (pw1 == pw2) $scope.result = 'correct';
else {
$scope.formData.passwordSaved = null;
$scope.result = 'incorrect';
}
} else
$scope.result = null;
} else
$scope.result = null;
};
$scope.resizeView = function() { $scope.resizeView = function() {
$timeout(function() { $timeout(function() {
$ionicScrollDelegate.resize(); $ionicScrollDelegate.resize();
}, 10); }, 10);
checkPasswordFields(); resetPasswordFields();
}; };
function checkPasswordFields() { function resetPasswordFields() {
if (!$scope.encrypt) { $scope.formData.passphrase = $scope.formData.createPassphrase = $scope.formData.passwordSaved = $scope.formData.repeatpassword = $scope.result = null;
$scope.formData.passphrase = $scope.formData.createPassphrase = $scope.formData.passwordSaved = null; $timeout(function() {
$timeout(function() { $scope.$apply();
$scope.$apply(); });
});
}
}; };
function updateRCSelect(n) { function updateRCSelect(n) {
@ -64,7 +78,7 @@ angular.module('copayApp.controllers').controller('createController',
id: 'new', id: 'new',
label: gettextCatalog.getString('Random'), label: gettextCatalog.getString('Random'),
supportsTestnet: true supportsTestnet: true
}, { }, {
id: 'set', id: 'set',
label: gettextCatalog.getString('Specify Recovery Phrase...'), label: gettextCatalog.getString('Specify Recovery Phrase...'),
supportsTestnet: false supportsTestnet: false

View file

@ -95,6 +95,21 @@
font-size: 16px; font-size: 16px;
} }
} }
input[type="password"] {
border: none;
margin-left: -5px;
padding-left: 4px;
&.incorrect {
margin-right: 10px;
border: 1px solid;
color: #C90505;
}
&.correct {
margin-right: 10px;
border: 1px solid;
color: #00901B;
}
}
} }
#tab-settings { #tab-settings {

View file

@ -35,7 +35,7 @@
<div class="input-label" translate> <div class="input-label" translate>
Wallet Key Wallet Key
</div> </div>
<select class="m10t" ng-model="seedSource" ng-options="seed as seed.label for seed in seedOptions"></select> <select class="m10t" ng-model="seedSource" ng-options="seed as seed.label for seed in seedOptions" ng-change="resizeView()"></select>
</label> </label>
<label class="item item-input item-stacked-label" ng-show="seedSource.id == 'trezor' || seedSource.id == 'ledger'"> <label class="item item-input item-stacked-label" ng-show="seedSource.id == 'trezor' || seedSource.id == 'ledger'">
@ -66,20 +66,41 @@
placeholder="{{'Password'|translate}}" placeholder="{{'Password'|translate}}"
type="password" type="password"
autocapitalize="off" autocapitalize="off"
ng-model="formData.createPassphrase"> ng-model="formData.createPassphrase"
ng-change="checkPassword(formData.createPassphrase, formData.repeatpassword)"
ng-class="{'correct': result == 'correct', 'incorrect': result == 'incorrect'}">
<input ng-show="seedSource.id == 'set'" <input ng-show="seedSource.id == 'set'"
placeholder="{{'Password'|translate}}" placeholder="{{'Password'|translate}}"
type="password" type="password"
autocapitalize="off" autocapitalize="off"
ng-model="formData.passphrase"> ng-model="formData.passphrase"
ng-change="checkPassword(formData.passphrase, formData.repeatpassword)"
ng-class="{'correct': result == 'correct', 'incorrect': result == 'incorrect'}">
</div>
<div class="item item-input" ng-show="encrypt">
<input ng-show="seedSource.id == 'new'"
placeholder="{{'Repeat password'|translate}}"
type="password"
autocapitalize="off"
ng-model="formData.repeatpassword"
ng-change="checkPassword(formData.createPassphrase, formData.repeatpassword)"
ng-class="{'correct': result == 'correct', 'incorrect': result == 'incorrect'}">
<input ng-show="seedSource.id == 'set'"
placeholder="{{'Repeat password'|translate}}"
type="password"
autocapitalize="off"
ng-model="formData.repeatpassword"
ng-change="checkPassword(formData.passphrase, formData.repeatpassword)"
ng-class="{'correct': result == 'correct', 'incorrect': result == 'incorrect'}">
</div> </div>
<div class="text-center box-notification error" ng-show="(seedSource.id =='new' || seedSource.id =='set') && encrypt"> <div class="text-center box-notification error" ng-show="(seedSource.id =='new' || seedSource.id =='set') && encrypt">
<strong translate>This password cannot be recovered. If the password is lost, there is no way you could recover your funds.</strong> <strong translate>This password cannot be recovered. If the password is lost, there is no way you could recover your funds.</strong>
</div> </div>
<ion-checkbox ng-model="formData.passwordSaved" class="checkbox-positive" ng-show="encrypt"> <ion-checkbox ng-model="formData.passwordSaved" class="checkbox-positive" ng-show="encrypt && result == 'correct'">
<span class="toggle-label" translate>I have written it down</span> <span class="toggle-label" translate>I have written it down</span>
</ion-checkbox> </ion-checkbox>