Skip to content
Snippets Groups Projects
Commit 694d4ca1 authored by Benoit Lavenier's avatar Benoit Lavenier
Browse files

[fix] Fix error on join wizard

parent 121afa67
No related branches found
No related tags found
No related merge requests found
......@@ -59,7 +59,7 @@ angular.module("cesium.config", [])
}
},
"version": "0.13.1",
"build": "2017-07-07T21:41:26.068Z",
"build": "2017-07-07T22:33:40.659Z",
"newIssueUrl": "https://github.com/duniter/cesium/issues/new?labels=bug"
})
......
......@@ -168,7 +168,7 @@ function JoinModalController($scope, $state, $interval, $timeout, UIUtils, Crypt
$scope.showAccountPubkey = function() {
$scope.formData.computing=true;
CryptoUtils.connect($scope.formData.username, $scope.formData.password)
CryptoUtils.scryptKeypair($scope.formData.username, $scope.formData.password)
.then(function(keypair) {
$scope.formData.pubkey = CryptoUtils.util.encode_base58(keypair.signPk);
$scope.formData.computing=false;
......@@ -318,56 +318,48 @@ function JoinModalController($scope, $state, $interval, $timeout, UIUtils, Crypt
UIUtils.loading.show();
csWallet.login($scope.formData.username, $scope.formData.password)
.then(function() {
if ($scope.accountType === "member") {
$scope.closeModal();
csSettings.data.wallet = csSettings.data.wallet || {};
csSettings.data.wallet.alertIfUnusedWallet = false; // do not alert if empty
// Redirect to wallet
$state.go('app.view_wallet');
// Send self
csWallet.self($scope.formData.pseudo, false/*do NOT load membership here*/)
.then(function() {
// Send membership IN
csWallet.membership.inside()
.then(function() {
return csWallet.login({auth: true, expectedPubkey: $scope.formData.pubkey, isNew: true})
.then(function() {
if ($scope.accountType === "member") {
$scope.closeModal();
csSettings.data.wallet = csSettings.data.wallet || {};
csSettings.data.wallet.alertIfUnusedWallet = false; // do not alert if empty
$scope.closeModal();
// Redirect to wallet
$state.go('app.view_wallet')
// Send self
return csWallet.self($scope.formData.pseudo, false/*do NOT load membership here*/)
.then(function() {
// Send membership IN
csWallet.membership.inside()
.then(function() {
$scope.downloadRevocationRegistration();
$scope.closeModal();
// Redirect to wallet
$state.go('app.view_wallet')
.then(function() {
$scope.downloadRevocationRegistration();
});
})
.catch(function(err) {
if (err && err.ucode != BMA.errorCodes.MEMBERSHIP_ALREADY_SEND) return;
onErrorLogout('ERROR.SEND_MEMBERSHIP_IN_FAILED')(err);
});
})
.catch(function(err) {
//
if (err && err.ucode == BMA.errorCodes.MEMBERSHIP_ALREADY_SEND) {
}
onErrorLogout('ERROR.SEND_MEMBERSHIP_IN_FAILED')(err);
});
})
.catch(onErrorLogout('ERROR.SEND_IDENTITY_FAILED'));
}
else{
csWallet.data.isNew = true;
$scope.closeModal();
.catch(onErrorLogout('ERROR.SEND_IDENTITY_FAILED'));
}
else{
$scope.closeModal();
//Redirect to wallet
$state.go('app.view_wallet');
// Redirect to wallet
$state.go('app.view_wallet');
}
})
.catch(function(err) {
UIUtils.loading.hide();
console.error('>>>>>>>' , err);
UIUtils.alert.error('ERROR.CRYPTO_UNKNOWN_ERROR');
});
}
})
.catch(function(err) {
UIUtils.loading.hide();
console.error('>>>>>>>' , err);
UIUtils.alert.error('ERROR.CRYPTO_UNKNOWN_ERROR');
});
};
$scope.downloadRevocationRegistration = function() {
......
......@@ -976,11 +976,10 @@ function WalletSecurityModalController($scope, UIUtils, csWallet, $translate, Cr
var salt = $scope.formData.username;
var pwd = $scope.formData.password;
CryptoUtils.connect(salt, pwd)
CryptoUtils.scryptKeypair(salt, pwd)
.then(function (keypair) {
$scope.pubkey = CryptoUtils.util.encode_base58(keypair.signPk);
})
.then(function () {
if (!csWallet.isUserPubkey($scope.pubkey)) {
UIUtils.alert.error('ERROR.SALT_OR_PASSWORD_NOT_CONFIRMED', 'ERROR.LOGIN_FAILED');
......
......@@ -122,9 +122,7 @@ angular.module('cesium.currency.services', ['ngApi', 'cesium.bma.services'])
});
}
function getData(options) {
options = options || {};
//options.current = angular.isDefined(options.current) ? options.current : false;
function getData() {
if (started) { // load only once
return $q.when(data);
......
......@@ -125,6 +125,7 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se
authData = res;
data.pubkey = res.pubkey;
data.isNew = angular.isDefined(options.isNew) ? options.isNew : data.isNew;
if (csSettings.data.keepAuthIdle) {
data.keypair = res.keypair || {
signSk: null,
......@@ -506,7 +507,8 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se
// Must be call after loadCurrency() and loadRequirements()
finishLoadRequirements = function(currency) {
data.requirements.needCertificationCount = (!data.requirements.needMembership && (data.requirements.certificationCount < currency.parameters.sigQty)) ?
currency = currency || csCurrency.data;
data.requirements.needCertificationCount = (!data.requirements.needMembership && (data.requirements.certificationCount < csCurrency.parameters.sigQty)) ?
(currency.parameters.sigQty - data.requirements.certificationCount) : 0;
data.requirements.willNeedCertificationCount = (!data.requirements.needMembership &&
data.requirements.needCertificationCount === 0 && (data.requirements.certificationCount - data.requirements.willExpireCertificationCount) < currency.parameters.sigQty) ?
......@@ -1234,7 +1236,7 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se
var nbCharSalt = Math.round(record.answer.length / 2);
var salt = record.answer.substr(0, nbCharSalt);
var pwd = record.answer.substr(nbCharSalt);
return CryptoUtils.connect(salt, pwd)
return CryptoUtils.scryptKeypair(salt, pwd)
.then(function (keypair) {
record.pubkey = CryptoUtils.util.encode_base58(keypair.signPk);
record.keypair = keypair;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment