diff --git a/www/i18n/locale-fr-FR.json b/www/i18n/locale-fr-FR.json index 6e408628..84c2f92d 100644 --- a/www/i18n/locale-fr-FR.json +++ b/www/i18n/locale-fr-FR.json @@ -564,6 +564,24 @@ "SELECT_WALLET_MODAL": { "TITLE": "Sélection du portefeuille" }, + "CERTIFICATION_MODAL": { + "CHECKLIST_TITLE": "Vérifications avant certification", + "INFOS": "La sécurité de la monnaie Ğ1 repose sur chaque membre. Avant de certifier l'identité de cette personne, vous devez avoir fait quelques vérifications à son propos. Veuillez répondre aux questions suivantes :", + "BTN_ALL_CHECK": "Certifier", + "CHECKLIST_CONDITIONS_NOT_MET": "La certification n'a pas été envoyée. Les vérifications semblent insuffisantes. Veuillez vérifier de nouveau chaque point auprès de la personne à certifier.", + "QUESTIONS": { + "WELL_KNOWN": "Connaissez-vous bien la personne que vous certifiez, et connaissez-vous des gens qui la connaissent bien également ?", + "REVOCATION": "A-t-elle téléchargé son document de révocation et sait-elle où le retrouver ?", + "CONTACT": "Avez-vous contacté cette personne par plusieurs moyens et vous a-t-elle répondu ?", + "DOUBLE_IDENTITY": "La personne possède-t-elle une autre identité membre active ?", + "MASTER_ACCOUNT": "Maîtrise-t-elle son compte, et a-t-elle déjà effectué au moins un virement depuis son compte ?", + "LICENSE": "A-t-elle compris la licence, et accepte-t-elle de s'y conformer pour la certification d'autres membres ?", + "CREDENTIALS": "L’identifiant et le mot de passe de son compte sont-ils longs et complexes (phrases de passe) ? A-t-elle compris que l’identifiant doit également rester secret ? Est-elle certaine de s’en souvenir ou de pouvoir les retrouver ?", + "PUBLIC_KEY_DIFFERENT": "La clef publique indiquée ici est-elle différente de celle que vous a communiqué cette personne ?" + }, + "REMINDER_TITLE": "Rappel", + "SHORT_LICENSE_REMINDER": "

Vous pouvez rappeler à la personne certifiée les paramètres des certifications :

- Chaque membre peut avoir émis 100 certifications valides au maximum.

- Les certifications sont enregistrées à un intervalle de 5 jours.

- Une nouvelle identité membre doit réunir au minimum 5 certifications en moins de deux mois.

- Un membre doit renouveler son adhésion chaque année.

- Les certifications sont valides durant deux ans.

" + }, "WALLET_LIST": { "TITLE": "Mes portefeuilles", "BTN_NEW": "Ajouter un portefeuille", @@ -808,8 +826,6 @@ "POPUP_TITLE": "Confirmation", "POPUP_WARNING_TITLE": "Avertissement", "POPUP_SECURITY_WARNING_TITLE": " Avertissement de sécurité", - "CERTIFY_RULES_TITLE_UID": "Certifier {{uid}}", - "CERTIFY_RULES": "Ne PAS certifier un compte si vous pensez que :


Êtes-vous sûr de vouloir néanmoins certifier cette identité ?", "FULLSCREEN": "Afficher l'application en plein écran ?", "EXIT_APP": "Fermer l'application ?", "TRANSFER": "Récapitulatif du virement :


Êtes-vous sûr de vouloir effectuer ce virement ?", diff --git a/www/js/controllers/wot-controllers.js b/www/js/controllers/wot-controllers.js index 4f109795..456b7ea3 100644 --- a/www/js/controllers/wot-controllers.js +++ b/www/js/controllers/wot-controllers.js @@ -157,6 +157,8 @@ angular.module('cesium.wot.controllers', ['cesium.services']) .controller('WotCertificationsViewCtrl', WotCertificationsViewController) + .controller('WotCertificationChecklistCtrl', WotCertificationChecklistController) + .controller('WotSelectPubkeyIdentityModalCtrl', WotSelectPubkeyIdentityModalController) ; @@ -783,15 +785,20 @@ function WotIdentityAbstractController($scope, $rootScope, $state, $translate, $ return; } - UIUtils.alert.confirm('CONFIRM.CERTIFY_RULES', 'CONFIRM.POPUP_SECURITY_WARNING_TITLE', { - cssClass: 'warning', - okText: 'WOT.BTN_YES_CERTIFY', - okType: 'button-assertive' - }) - .then(function(confirm){ - if (!confirm) { - return; + // Certification checklist before confirmation + let answers_are_right = $q.defer(); + answers_are_right.promise.then(function(){ + UIUtils.alert.confirm( + 'ACCOUNT.CERTIFICATION_MODAL.SHORT_LICENSE_REMINDER', + 'ACCOUNT.CERTIFICATION_MODAL.REMINDER_TITLE', + { + cssClass: 'positive', + okText: 'COMMON.BTN_OK', + okType: 'button-positive' } + ) + .then(function(confirm){ + if (! confirm) {return} UIUtils.loading.show(); wallet.certify($scope.formData.uid, $scope.formData.pubkey, @@ -811,7 +818,18 @@ function WotIdentityAbstractController($scope, $rootScope, $state, $translate, $ } }) .catch(UIUtils.onError('ERROR.SEND_CERTIFICATION_FAILED')); - }); + }) + }) + .catch( + UIUtils.onError('ACCOUNT.CERTIFICATION_MODAL.CHECKLIST_CONDITIONS_NOT_MET') + ); + + // display certification checklist modal + return Modals.showCertificationCheckList({ + answers_are_right: answers_are_right, + identity: $scope.formData, + }); + }) .catch(function(err) { if (err === 'CANCELLED') return; @@ -889,17 +907,21 @@ function WotIdentityAbstractController($scope, $rootScope, $state, $translate, $ return; } - // Ask confirmation - $translate('CONFIRM.CERTIFY_RULES_TITLE_UID', {uid: identity.uid}) - .then(function (confirmTitle) { - return UIUtils.alert.confirm('CONFIRM.CERTIFY_RULES', confirmTitle); - }) - .then(function (confirm) { - if (!confirm) { - return; + // Certification checklist before confirmation + let answers_are_right = $q.defer(); + answers_are_right.promise.then(function(){ + UIUtils.alert.confirm( + 'ACCOUNT.CERTIFICATION_MODAL.SHORT_LICENSE_REMINDER', + 'ACCOUNT.CERTIFICATION_MODAL.REMINDER_TITLE', + { + cssClass: 'positive', + okText: 'COMMON.BTN_OK', + okType: 'button-positive' } + ) + .then(function(confirm){ + if (! confirm) {return} UIUtils.loading.show(); - // Send certification wallet.certify(identity.uid, identity.pubkey, @@ -917,8 +939,19 @@ function WotIdentityAbstractController($scope, $rootScope, $state, $translate, $ $scope.doMotion(); }); }) - .catch(UIUtils.onError('ERROR.SEND_CERTIFICATION_FAILED')); - }); + .catch(UIUtils.onError('ERROR.SEND_CERTIFICATION_FAILED')); + }) + }) + .catch( + UIUtils.onError('ACCOUNT.CERTIFICATION_MODAL.CHECKLIST_CONDITIONS_NOT_MET') + ); + + // Display cert checklist modal + return Modals.showCertificationCheckList({ + answers_are_right: answers_are_right, + identity: identity, + }); + }) .catch(function (err) { if (err === 'CANCELLED') return; @@ -1429,6 +1462,88 @@ function WotCertificationsViewController($scope, $rootScope, $controller, csSett }; } +/** + * Certification checklist controller + * @param $controller + */ + function WotCertificationChecklistController($scope, $controller, parameters){ + + // allow to display license + $controller('CurrencyViewCtrl', {$scope: $scope}); + + let answers_are_right = parameters.answers_are_right; + $scope.identity = parameters.identity; + + $scope.prepare_cert_checklist = function() { + const original_cert_checklist = [ + { + question: 'ACCOUNT.CERTIFICATION_MODAL.QUESTIONS.WELL_KNOWN', + expected_answer: true, + answer: false + }, + { + question: 'ACCOUNT.CERTIFICATION_MODAL.QUESTIONS.REVOCATION', + expected_answer: true, + answer: false + }, + { + question: 'ACCOUNT.CERTIFICATION_MODAL.QUESTIONS.CONTACT', + expected_answer: true, + answer: false + }, + { + question: 'ACCOUNT.CERTIFICATION_MODAL.QUESTIONS.MASTER_ACCOUNT', + expected_answer: true, + answer: false + }, + { + question: 'ACCOUNT.CERTIFICATION_MODAL.QUESTIONS.LICENSE', + expected_answer: true, + answer: false + }, + { + question: 'ACCOUNT.CERTIFICATION_MODAL.QUESTIONS.CREDENTIALS', + expected_answer: true, + answer: false + }, + // questions with negative answers + { + question: 'ACCOUNT.CERTIFICATION_MODAL.QUESTIONS.DOUBLE_IDENTITY', + expected_answer: false, + answer: false + }, + { + question: 'ACCOUNT.CERTIFICATION_MODAL.QUESTIONS.PUBLIC_KEY_DIFFERENT', + expected_answer: false, + answer: false + }, + ]; + + // Fisher-Yates shuffle + function shuffle(array) { + for (let i = array.length - 1; i > 0; i--) { + let j = Math.floor(Math.random() * (i + 1)); // random index from 0 to i + let t = array[i]; array[i] = array[j]; array[j] = t + } + return array; + } + + return shuffle(original_cert_checklist).slice(0, 5); + } + $scope.cert_checklist = $scope.prepare_cert_checklist(); + + $scope.verifyAnswers = function() { + $scope.cert_checklist.map( question => { + if (question.answer !== question.expected_answer) { + // TODO message should be changed. + answers_are_right.reject(); + } + }); + answers_are_right.resolve(true); + + $scope.closeModal(); + } +} /** * Select identities from a pubkey (useful when many self on the same pubkey) diff --git a/www/js/services/modal-services.js b/www/js/services/modal-services.js index 3ff97d62..4cd65471 100644 --- a/www/js/services/modal-services.js +++ b/www/js/services/modal-services.js @@ -232,6 +232,10 @@ angular.module('cesium.modal.services', ['cesium.utils.services']) parameters); } + function showCertificationCheckList(parameters) { + return ModalUtils.show('templates/wot/modal_certification_checklist.html','WotCertificationChecklistCtrl', parameters); + } + function showSelectPubkeyIdentity(parameters) { return ModalUtils.show('templates/wot/modal_select_pubkey_identity.html', 'WotSelectPubkeyIdentityModalCtrl', parameters); @@ -294,6 +298,7 @@ angular.module('cesium.modal.services', ['cesium.utils.services']) showHelp: showHelp, showAccountSecurity: showAccountSecurity, showLicense: showLicense, + showCertificationCheckList: showCertificationCheckList, showSelectPubkeyIdentity: showSelectPubkeyIdentity, showSelectWallet: showSelectWallet, showPassword: showPassword diff --git a/www/templates/wot/item_checklist_certification.html b/www/templates/wot/item_checklist_certification.html new file mode 100644 index 00000000..a4e5b983 --- /dev/null +++ b/www/templates/wot/item_checklist_certification.html @@ -0,0 +1,17 @@ +
+
+
+
+
+ COMMON.BTN_YES + COMMON.BTN_NO +
+
+
+ +
\ No newline at end of file diff --git a/www/templates/wot/modal_certification_checklist.html b/www/templates/wot/modal_certification_checklist.html new file mode 100644 index 00000000..5ba91990 --- /dev/null +++ b/www/templates/wot/modal_certification_checklist.html @@ -0,0 +1,80 @@ + + + + + + + + + +

ACCOUNT.CERTIFICATION_MODAL.CHECKLIST_TITLE

+ + + + + + + +
+ + + + + +
{{ identity.uid }} - {{ identity.pubkey }}
+ +
ACCOUNT.CERTIFICATION_MODAL.INFOS
+ +
+
+
+
+ + +
+ + + + + + + +
+
+
\ No newline at end of file