Commit 1827a7f8 authored by Benoit Lavenier's avatar Benoit Lavenier

[fix] Assistant de création de compte > Message d'erreur furtif - FIX #715

parent fa6617e4
......@@ -185,12 +185,16 @@ function JoinModalController($scope, $state, $interval, $timeout, Device, UIUtil
CryptoUtils.scryptKeypair($scope.formData.username, $scope.formData.password)
.then(function(keypair) {
$scope.formData.pubkey = CryptoUtils.util.encode_base58(keypair.signPk);
$scope.formData.computing=false;
$scope.checkAccountAvailable();
return $scope.checkAccountAvailable();
})
.then(function() {
return $timeout(function(){
$scope.formData.computing=false;
}, 400);
})
.catch(function(err) {
$scope.formData.computing=false;
$scope.formData.pubkey = undefined;
$scope.formData.computing=false;
UIUtils.onError('ERROR.CRYPTO_UNKNOWN_ERROR')(err);
});
};
......@@ -301,6 +305,11 @@ function JoinModalController($scope, $state, $interval, $timeout, Device, UIUtil
$scope.slideBehavior = $scope.computeSlideBehavior();
};
$scope.doPrev = function() {
$scope.slidePrev();
$scope.slideBehavior = $scope.computeSlideBehavior();
};
$scope.doNewAccount = function(confirm) {
if (!confirm) {
......@@ -462,27 +471,25 @@ function JoinModalController($scope, $state, $interval, $timeout, Device, UIUtil
$scope.checkAccountAvailable = function() {
delete $scope.accountAvailable;
// Search for tx source, from pubkey
BMA.tx.sources({ pubkey: $scope.formData.pubkey })
return BMA.tx.sources({ pubkey: $scope.formData.pubkey })
.then(function(res) {
if(!res.sources.length) {
$scope.formData.computing=false;
$scope.accountAvailable = true;
}
else{
$scope.formData.computing=false;
$scope.accountAvailable = false;
}
$scope.accountAvailable = !res || !res.sources.length;
})
.catch(function(err) {
console.error(err);
$scope.formData.computing=false;
$scope.accountAvailable = false;
});
};
$scope.identifierRecovery = function() {
for (var i = 0; i < 2; i++)
$scope.slidePrev();
// Go back
$scope.slides.slider.unlockSwipes();
for (var i = 0; i < 2; i++) {
$scope.slides.slider.slidePrev();
}
$scope.slides.slider.lockSwipes();
// Recompute behavior
$scope.slideBehavior = $scope.computeSlideBehavior();
};
// TODO: remove auto add account when done
......
......@@ -7,7 +7,7 @@
ng-click="closeModal()" translate>COMMON.BTN_CANCEL
</button>
<button class="button button-icon button-clear icon ion-ios-arrow-back buttons header-item"
ng-click="slidePrev()"
ng-click="doPrev()"
ng-if="slides.slider.activeIndex && slideBehavior.hasPreviousButton">
</button>
<button class="button button-icon button-clear icon ion-ios-help-outline visible-xs"
......@@ -356,60 +356,62 @@
</div>
<!-- Account available -->
<div ng-if="accountAvailable && !formData.computing">
<div class="padding text-center" translate>ACCOUNT.NEW.LAST_SLIDE_CONGRATULATION</div>
<ng-if ng-if="!formData.computing">
<div class="animate-fade-in animate-show-hide ng-hide" ng-show="accountAvailable">
<div class="padding text-center" translate>ACCOUNT.NEW.LAST_SLIDE_CONGRATULATION</div>
<div class="list">
<div class="list">
<ion-item class="item text-center item-text-wrap">
<h3 class="gray" translate>LOGIN.ASSOCIATED_PUBKEY</h3>
<!-- do NOT add copy-on-click attribute here - see issue #470-->
<h3 class="dark bold">
{{formData.pubkey}}
</h3>
</ion-item>
</div>
<ion-item class="item text-center item-text-wrap">
<h3 class="gray" translate>LOGIN.ASSOCIATED_PUBKEY</h3>
<!-- do NOT add copy-on-click attribute here - see issue #470-->
<h3 class="dark bold">
{{formData.pubkey}}
</h3>
</ion-item>
</div>
<div class="padding hidden-xs text-right">
<button class="button button-clear button-dark ink" ng-click="closeModal()" type="button" translate>COMMON.BTN_CANCEL
</button>
<button class="button button-positive ink" ng-click="doNewAccount()" translate>
COMMON.BTN_SEND
<i class="icon ion-android-send"></i>
</button>
<div class="padding hidden-xs text-right">
<button class="button button-clear button-dark ink" ng-click="closeModal()" type="button" translate>COMMON.BTN_CANCEL
</button>
<button class="button button-positive ink" ng-click="doNewAccount()" translate>
COMMON.BTN_SEND
<i class="icon ion-android-send"></i>
</button>
</div>
</div>
</div>
<!-- Existing non-empty account -->
<div ng-if="!accountAvailable && !formData.computing">
<!-- Existing non-empty account -->
<div class="animate-fade-in animate-show-hide ng-hide" ng-show="!accountAvailable">
<ion-item class="item-icon-left item-text-wrap text-center">
<i class="icon ion-minus-circled assertive"></i>
<span id="modal-license" trust-as-html="'ERROR.EXISTING_ACCOUNT'|translate"></span>
</ion-item>
<ion-item class="item-icon-left item-text-wrap text-center">
<i class="icon ion-minus-circled assertive"></i>
<span id="modal-license" trust-as-html="'ERROR.EXISTING_ACCOUNT'|translate"></span>
</ion-item>
<div class="list">
<div class="list">
<ion-item class="item item-text-wrap item-border">
<div class="padding text-center">
<span class="gray text-no-wrap">
{{formData.pubkey}}
</span>
</div>
</ion-item>
<ion-item class="item item-text-wrap item-border">
<div class="padding text-center">
<span class="gray text-no-wrap">
{{formData.pubkey}}
</span>
<span translate>ERROR.EXISTING_ACCOUNT_REQUEST</span>
</div>
</ion-item>
<div class="padding text-center">
<span translate>ERROR.EXISTING_ACCOUNT_REQUEST</span>
</div>
</div>
<div class="padding hidden-xs text-left">
<button class="button button-assertive icon-left ion-chevron-left ink"
ng-click="identifierRecovery()" translate>
COMMON.BTN_MODIFY
</button>
<div class="padding hidden-xs text-left">
<button class="button button-assertive icon-left ion-chevron-left ink"
ng-click="identifierRecovery()" translate>
COMMON.BTN_MODIFY
</button>
</div>
</div>
</div>
</ng-if>
</ion-content>
</ion-slide-page>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment