Skip to content

Commit

Permalink
[fix] Fix default wallet "self " selection,, when many identities wit…
Browse files Browse the repository at this point in the history
…h some with a bad block timestamp.
  • Loading branch information
blavenie committed Oct 30, 2018
1 parent 172198a commit 0215204
Show file tree
Hide file tree
Showing 10 changed files with 218 additions and 139 deletions.
1 change: 1 addition & 0 deletions www/i18n/locale-en-GB.json
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,7 @@
"NOT_NEED_MEMBERSHIP": "Already a member.",
"IDENTITY_WILL_MISSING_CERTIFICATIONS": "This identity will soon lack certification (at least {{willNeedCertificationCount}}).",
"IDENTITY_NEED_MEMBERSHIP": "This identity did not send a membership request. She will have to if she wishes to become a member.",
"HAS_ALTERNATIVE_IDENTITIES": "There are <b>multiple identities</b> attached to this public key. <b>Before any certification</b>, please <a ng-click=\"doQuickFix('showSelectIdentities')\">check other identities</a> to choose the correct one, or contact the wallet owner.",
"REVOCATION_SENT": "Revocation sent successfully",
"REVOCATION_SENT_WAITING_PROCESS": "Revocation <b>has been sent successfully</b>. It is awaiting processing.",
"FEATURES_NOT_IMPLEMENTED": "This features is not implemented yet.<br/><br/>Why not to contribute to get it faster? ;)",
Expand Down
1 change: 1 addition & 0 deletions www/i18n/locale-en.json
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,7 @@
"NOT_NEED_MEMBERSHIP": "Already a member.",
"IDENTITY_WILL_MISSING_CERTIFICATIONS": "This identity will soon lack certification (at least {{willNeedCertificationCount}}).",
"IDENTITY_NEED_MEMBERSHIP": "This identity did not send a membership request. She will have to if she wishes to become a member.",
"HAS_ALTERNATIVE_IDENTITIES": "There are <b>multiple identities</b> attached to this public key. <b>Before any certification</b>, please <a ng-click=\"doQuickFix('showSelectIdentities')\">check other identities</a> to choose the correct one, or contact the wallet owner.",
"REVOCATION_SENT": "Revocation sent successfully",
"REVOCATION_SENT_WAITING_PROCESS": "Revocation <b>has been sent successfully</b>. It is awaiting processing.",
"FEATURES_NOT_IMPLEMENTED": "This features is not implemented yet.<br/><br/>Why not to contribute to get it faster? ;)",
Expand Down
1 change: 1 addition & 0 deletions www/i18n/locale-es-ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@
"NOT_NEED_MEMBERSHIP": "Ya es miembro.",
"IDENTITY_WILL_MISSING_CERTIFICATIONS": "Esta identidad pronto va a necesitar certificaciones (al menos {{willNeedCertificationCount}}).",
"IDENTITY_NEED_MEMBERSHIP": "Esta identidad no envió una solicitud de membresía. Ella tendrá que hacerlo si desea hacerse miembro.",
"HAS_ALTERNATIVE_IDENTITIES": "Hay <b>identidades múltiples</b> adjuntas a esta clave pública. <b>Antes de cualquier certificación</b>, <a ng-click=\"doQuickFix('showSelectIdentities')\">verifique otras identidades</a> para elegir la correcta o comuníquese con el propietario de la cuenta.",
"REVOCATION_SENT": "Revocación enviada",
"REVOCATION_SENT_WAITING_PROCESS": "La <b>revocación de esta identidad</b> fue solicitada y está en espera de ser procesada.",
"FEATURES_NOT_IMPLEMENTED": "Esta funcionalidad todavía está en proceso de desarrollo.<br/><br/>¿Por qué no <b>contribuir a Cesium</b>, para obtenerla más rápido? ;)",
Expand Down
1 change: 1 addition & 0 deletions www/i18n/locale-fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,7 @@
"NOT_NEED_MEMBERSHIP": "Vous êtes déjà membre.",
"IDENTITY_WILL_MISSING_CERTIFICATIONS": "Cette identité va bientôt manquer de certification (au moins {{willNeedCertificationCount}}).",
"IDENTITY_NEED_MEMBERSHIP": "Cette identité n'a pas envoyée de demande d'adhésion. Elle devra si elle souhaite devenir membre.",
"HAS_ALTERNATIVE_IDENTITIES": "Il existe <b>plusieurs identités</b> rattachées à cette clé publique. <b>Avant toute certification</b>, pensez à <a ng-click=\"doQuickFix('showSelectIdentities')\">consulter les autres identités</a> pour choisir la bonne, ou bien contacter le propriétaire du compte.",
"REVOCATION_SENT": "Revocation envoyée",
"REVOCATION_SENT_WAITING_PROCESS": "La <b>révocation de cette identité</b> a été demandée et est en attente de traitement.",
"FEATURES_NOT_IMPLEMENTED": "Cette fonctionnalité est encore en cours de développement.<br/>Pourquoi ne pas <b>contribuer à Cesium</b>, pour l'obtenir plus rapidement ? ;)",
Expand Down
2 changes: 1 addition & 1 deletion www/js/controllers/wallet-controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ function WalletController($scope, $rootScope, $q, $ionicPopup, $timeout, $state,

var title = $scope.formData.name || $scope.formData.uid || $scope.formData.pubkey;
// Use shareBasePath (fix #530) or rootPath (fix #390)
var url = (csConfig.shareBaseUrl || $rootScope.rootPath) + $state.href('app.wot_identity', {pubkey: $scope.formData.pubkey, uid: $scope.formData.name || $scope.formData.uid});
var url = (csConfig.shareBaseUrl || $rootScope.rootPath) + $state.href('app.wot_identity', {pubkey: $scope.formData.pubkey, uid: $scope.formData.uid});

// Override default position, is small screen - fix #545
if (UIUtils.screen.isSmall()) {
Expand Down
24 changes: 23 additions & 1 deletion www/js/controllers/wot-controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ function WotIdentityAbstractController($scope, $rootScope, $state, $translate, $
/**
* Identity view controller - should extend WotIdentityAbstractCtrl
*/
function WotIdentityViewController($scope, $rootScope, $controller, $timeout, UIUtils, csWallet) {
function WotIdentityViewController($scope, $rootScope, $controller, $timeout, $state, UIUtils, Modals, csWallet) {
'ngInject';
// Initialize the super class and extend it.
angular.extend(this, $controller('WotIdentityAbstractCtrl', {$scope: $scope}));
Expand Down Expand Up @@ -1044,6 +1044,28 @@ function WotIdentityViewController($scope, $rootScope, $controller, $timeout, UI
$scope.showFab('fab-certify-' + $scope.formData.uid);
}
};

$scope.doQuickFix = function(event) {
if (event == "showSelectIdentities") {
return $scope.showSelectIdentities();
}
};

$scope.showSelectIdentities = function() {
if (!$scope.formData.requirements || !$scope.formData.requirements.alternatives) return;

return Modals.showSelectPubkeyIdentity({
identities: [$scope.formData.requirements].concat($scope.formData.requirements.alternatives)
})
.then(function(res) {
if (!res || !res.pubkey) return; // Skip if cancelled
// open the identity
return $state.go('app.wot_identity', {
pubkey: res.pubkey,
uid: res.uid
});
});
};
}

/**
Expand Down
36 changes: 4 additions & 32 deletions www/js/services/wallet-services.js
Original file line number Diff line number Diff line change
Expand Up @@ -687,35 +687,7 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se
cleanEventsByContext('requirements');

// Get requirements
return csWot.loadRequirements(data)
.then(function(){

if (!data.requirements.uid) return;

// Get sigDate
var blockParts = data.requirements.blockUid.split('-', 2);
var blockNumber = parseInt(blockParts[0]);
var blockHash = blockParts[1];
// Retrieve registration date
return BMA.blockchain.block({block: blockNumber})
.then(function(block) {
data.sigDate = block.medianTime;

// Check if self has been done on a valid block
if (!data.isMember && blockNumber !== 0 && blockHash !== block.hash) {
data.requirements.hasBadSelfBlock = true;
}
})
.catch(function(err){
// Special case for currency init (root block not exists): use now
if (err && err.ucode == BMA.errorCodes.BLOCK_NOT_FOUND && blockNumber === 0) {
data.sigDate = moment().utc().unix();
}
else {
throw err;
}
});
});
return csWot.loadRequirements(data);
},

loadTxAndSources = function(fromTime) {
Expand Down Expand Up @@ -746,15 +718,15 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se
addEvents = function() {
// Add user events
if (data.requirements.revoked) {
delete data.requirements.hasBadSelfBlock;
delete data.requirements.meta.invalid;
addEvent({type:'info', message: 'ERROR.WALLET_REVOKED', context: 'requirements'});
}
else if (data.requirements.pendingRevocation) {
delete data.requirements.hasBadSelfBlock;
delete data.requirements.meta.invalid;
addEvent({type:'pending', message: 'INFO.REVOCATION_SENT_WAITING_PROCESS', context: 'requirements'});
}
else {
if (!data.isMember && data.requirements.hasBadSelfBlock) {
if (!data.isMember && data.requirements.meta.invalid) {
addEvent({type: 'error', message: 'ERROR.WALLET_INVALID_BLOCK_HASH', context: 'requirements'});
console.debug("Invalid membership for uid={0}: block hash changed".format(data.uid));
}
Expand Down
Loading

0 comments on commit 0215204

Please sign in to comment.