diff --git a/README.md b/README.md index f425d0ae44bd0abd6508671aefa22ef9c460348e..f7a448a9113f5f701dece0ff8145ab38bbf001de 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ npm start ``` Answer asked questions. -Your cesium instance is now reacheable on : [http://localhost:8100/](http://localhost:8100/) or an other ip if your listen on an other interface. +Your Cesium instance is now reacheable on : [http://localhost:8100/](http://localhost:8100/) or an other ip if your listen on an other interface. #### Installation script diff --git a/www/plugins/es/js/controllers/wot-controllers.js b/www/plugins/es/js/controllers/wot-controllers.js index 8583c3baefaaeecf0c67ccf061573212499aee24..e9f94589bbc081bbdd16426f243c5104d0b50157 100644 --- a/www/plugins/es/js/controllers/wot-controllers.js +++ b/www/plugins/es/js/controllers/wot-controllers.js @@ -82,7 +82,7 @@ function ESWotLookupExtendController($scope, $controller, $state) { }; } -function ESWotIdentityViewController($scope, $ionicPopover, $q, UIUtils, Modals, esSettings, PluginService, +function ESWotIdentityViewController($scope, $ionicPopover, $q, UIUtils, Modals, esSettings, PluginService, csWallet, esModals, esHttp, esWallet, esInvitation) { 'ngInject'; @@ -128,14 +128,17 @@ function ESWotIdentityViewController($scope, $ionicPopover, $q, UIUtils, Modals, $scope.hideCertificationActionsPopover(); - var walletData; var identities; - return $scope.loadWallet({minData: true}) - .then(function(data) { + return csWallet.auth({minData: true}) + .then(function(walletData) { UIUtils.loading.hide(); - walletData = data; + // Not allow for non-member - issue #561 + if (!walletData.isMember) { + return UIUtils.alert.error('ERROR.ONLY_MEMBER_CAN_EXECUTE_THIS_ACTION'); + } + return Modals.showWotLookup({ allowMultiple: true, enableFilter: true, @@ -143,56 +146,58 @@ function ESWotIdentityViewController($scope, $ionicPopover, $q, UIUtils, Modals, help: 'WOT.SUGGEST_CERTIFICATIONS_MODAL.HELP', okText: 'COMMON.BTN_NEXT', okType: 'button-positive' - }); - }) - - .then(function(res) { - if (!res || !res.length) return; // user cancelled - identities = res; + }) + .then(function(res) { + if (!res || !res.length) return; // user cancelled + identities = res; - return $q.all([ + return $q.all([ // Get keypair only once (if not done here, certification.send() with compute it many times) esWallet.box.getKeypair(walletData.keypair), // Ask confirmation UIUtils.alert.confirm('WOT.CONFIRM.SUGGEST_CERTIFICATIONS', undefined, {okText: 'COMMON.BTN_SEND'}) ]) - .then(function(res) { - if (!res) return; - var keypair = res[0]; - var confirm = res[1]; - if (!confirm) return; - var time = esHttp.date.now(); // use same date for each invitation - return $q.all( - identities.reduce(function(res, identity){ - return res.concat( - esInvitation.send({ - issuer: walletData.pubkey, - recipient: $scope.formData.pubkey, - time: time, - content: [identity.uid, identity.pubkey].join('-') - }, keypair, 'certification') - ); - }, []) - ); - }) - .then(function() { - UIUtils.toast.show('INVITATION.INFO.INVITATION_SENT'); - }) - .catch(UIUtils.onError('INVITATION.ERROR.SEND_INVITATION_FAILED')); - }) - ; + .then(function(res) { + if (!res) return; + var keypair = res[0]; + var confirm = res[1]; + if (!confirm) return; + var time = esHttp.date.now(); // use same date for each invitation + return $q.all( + identities.reduce(function(res, identity){ + return res.concat( + esInvitation.send({ + issuer: walletData.pubkey, + recipient: $scope.formData.pubkey, + time: time, + content: [identity.uid, identity.pubkey].join('-') + }, keypair, 'certification') + ); + }, []) + ); + }) + .then(function() { + UIUtils.toast.show('INVITATION.INFO.INVITATION_SENT'); + }) + .catch(UIUtils.onError('INVITATION.ERROR.SEND_INVITATION_FAILED')); + }) + ; + }); }; $scope.showAskCertificationModal = function() { $scope.hideCertificationActionsPopover(); - var walletData; var identities; - return $scope.loadWallet({minData: true}) - .then(function(data) { + return csWallet.auth({minData: true}) + .then(function(walletData) { UIUtils.loading.hide(); - walletData = data; + + // Not allow for non-member - issue #561 + if (!walletData.isMember) { + return UIUtils.alert.error('ERROR.ONLY_MEMBER_CAN_EXECUTE_THIS_ACTION'); + } return Modals.showWotLookup({ allowMultiple: true, @@ -201,38 +206,38 @@ function ESWotIdentityViewController($scope, $ionicPopover, $q, UIUtils, Modals, help: 'WOT.ASK_CERTIFICATIONS_MODAL.HELP', okText: 'COMMON.BTN_NEXT', okType: 'button-positive' - }); - }) - .then(function(res) { - if (!res || !res.length) return; // user cancelled - identities = res; + }) + .then(function(res) { + if (!res || !res.length) return; // user cancelled + identities = res; - return $q.all([ + return $q.all([ // Get keypair only once (if not done here, certification.send() with compute it many times) esWallet.box.getKeypair(walletData.keypair), // Ask confirmation UIUtils.alert.confirm('WOT.CONFIRM.ASK_CERTIFICATIONS', undefined, {okText: 'COMMON.BTN_SEND'}) ]) - .then(function(res) { - if (!res) return; - var keypair = res[0]; - var confirm = res[1]; - if (!confirm) return; - var time = esHttp.date.now(); // use same date for each invitation - return $q.all(identities.reduce(function(res, identity){ - return res.concat( - esInvitation.send({ - issuer: walletData.pubkey, - recipient: identity.pubkey, - time: time, - content: [walletData.uid, walletData.pubkey].join('-') - }, keypair, 'certification') - ); - }, [])) - .then(function() { - UIUtils.toast.show('INVITATION.INFO.INVITATION_SENT'); - }) - .catch(UIUtils.onError('INVITATION.ERROR.SEND_INVITATION_FAILED')); + .then(function(res) { + if (!res) return; + var keypair = res[0]; + var confirm = res[1]; + if (!confirm) return; + var time = esHttp.date.now(); // use same date for each invitation + return $q.all(identities.reduce(function(res, identity){ + return res.concat( + esInvitation.send({ + issuer: walletData.pubkey, + recipient: identity.pubkey, + time: time, + content: [walletData.uid, walletData.pubkey].join('-') + }, keypair, 'certification') + ); + }, [])) + .then(function() { + UIUtils.toast.show('INVITATION.INFO.INVITATION_SENT'); + }) + .catch(UIUtils.onError('INVITATION.ERROR.SEND_INVITATION_FAILED')); + }); }); }); }; @@ -240,10 +245,15 @@ function ESWotIdentityViewController($scope, $ionicPopover, $q, UIUtils, Modals, $scope.askCertification = function() { $scope.hideCertificationActionsPopover(); - $scope.loadWallet({minData: true}) + return csWallet.auth({minData: true}) .then(function(walletData) { UIUtils.loading.hide(); + // Not allow for non-member - issue #561 + if (!walletData.isMember) { + return UIUtils.alert.error('ERROR.ONLY_MEMBER_CAN_EXECUTE_THIS_ACTION'); + } + return UIUtils.alert.confirm('WOT.CONFIRM.ASK_CERTIFICATION', undefined, { okText: 'COMMON.BTN_SEND' })