Merge pull request #6097 from gabrielbazan7/feat/verfpassphrase

adding verification option to passphrase and general refactor
This commit is contained in:
Gustavo Maximiliano Cortez 2017-05-23 12:09:40 -03:00 committed by GitHub
commit 270a7e3373
7 changed files with 211 additions and 120 deletions

View file

@ -19,37 +19,51 @@ angular.module('copayApp.controllers').controller('createController',
12: 1,
};
$scope.init = function(tc) {
$scope.$on("$ionicView.beforeEnter", function(event, data) {
$scope.formData = {};
var defaults = configService.getDefaults();
var tc = $state.current.name == 'tabs.add.create-personal' ? 1 : defaults.wallet.totalCopayers;
$scope.formData.account = 1;
$scope.formData.bwsurl = defaults.bws.url;
$scope.TCValues = lodash.range(2, defaults.limits.totalCopayers + 1);
$scope.formData.totalCopayers = defaults.wallet.totalCopayers;
$scope.formData.derivationPath = derivationPathHelper.default;
$scope.setTotalCopayers(tc);
updateRCSelect(tc);
};
resetPasswordFields();
});
$scope.showAdvChange = function() {
$scope.showAdv = !$scope.showAdv;
$scope.encrypt = null;
$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() {
$timeout(function() {
$ionicScrollDelegate.resize();
}, 10);
checkPasswordFields();
resetPasswordFields();
};
function checkPasswordFields() {
if (!$scope.encrypt) {
$scope.formData.passphrase = $scope.formData.createPassphrase = $scope.formData.passwordSaved = null;
$timeout(function() {
$scope.$apply();
});
}
function resetPasswordFields() {
$scope.formData.passphrase = $scope.formData.createPassphrase = $scope.formData.passwordSaved = $scope.formData.repeatPassword = $scope.result = null;
$timeout(function() {
$scope.$apply();
});
};
function updateRCSelect(n) {
@ -64,7 +78,7 @@ angular.module('copayApp.controllers').controller('createController',
id: 'new',
label: gettextCatalog.getString('Random'),
supportsTestnet: true
}, {
}, {
id: 'set',
label: gettextCatalog.getString('Specify Recovery Phrase...'),
supportsTestnet: false
@ -112,11 +126,7 @@ angular.module('copayApp.controllers').controller('createController',
updateSeedSourceSelect(tc);
};
$scope.create = function(form) {
if (form && form.$invalid) {
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Please enter the required fields'));
return;
}
$scope.create = function() {
var opts = {
name: $scope.formData.walletName,