From 8bc518346e9189cf302e14c1590ee2ed1fa09cef Mon Sep 17 00:00:00 2001
From: blavenie <benoit.lavenier@e-is.pro>
Date: Fri, 20 Oct 2017 19:36:17 +0200
Subject: [PATCH] [fix] Join wizard : avoid to use same salt and password - fix
 #588 [fix] Fix revocation i18n

---
 www/i18n/locale-en-GB.json                    |  6 ++-
 www/i18n/locale-en.json                       |  6 ++-
 www/i18n/locale-es-ES.json                    | 26 +++++++++----
 www/i18n/locale-fr-FR.json                    |  7 +++-
 www/js/config.js                              | 39 ++++++-------------
 www/js/controllers/join-controllers.js        | 10 +++--
 www/js/directives.js                          | 18 +++++++++
 www/templates/join/modal_join_member.html     | 11 ++++++
 www/templates/wallet/modal_security.html      |  2 +-
 .../wallet/slides/slides_revocation_file.html |  2 +-
 10 files changed, 83 insertions(+), 44 deletions(-)

diff --git a/www/i18n/locale-en-GB.json b/www/i18n/locale-en-GB.json
index 1fb48ee09..649f01379 100644
--- a/www/i18n/locale-en-GB.json
+++ b/www/i18n/locale-en-GB.json
@@ -233,6 +233,7 @@
       "SIG_STOCK": "Maximum number of certifications sent by a member",
       "SIG_PERIOD": "Minimum delay between 2 certifications sent by one and the same issuer.",
       "SIG_WINDOW": "Maximum delay before a certification will be treated",
+      "SIG_VALIDITY": "Lifetime of a certification that has been treated",
       "MS_WINDOW": "Maximum delay before a pending membership will be treated",
       "STEP_MAX": "Maximum distance between a newcomer and each referring members.",
       "WOT_RULES_DIVIDER": "Rules for web of trust",
@@ -534,7 +535,8 @@
       "RECOVER_ID": "Recover my password...",
       "RECOVER_ID_HELP": "If you have a <b>backup file of your identifiers</b>, you can find them by answering your personal questions correctly.",
       "REVOCATION_WITH_FILE" : "Rekoke my member account...",
-      "REVOCATION_WITH_FILE_HELP": "If you have <b>permanently lost your member account credentials (or if account security is compromised), you can use <b>the revocation file</b> of the account <b>to quit the Web Of Trust</b>.",
+      "REVOCATION_WITH_FILE_DESCRIPTION": "If you have <b>permanently lost your member account credentials (or if account security is compromised), you can use <b>the revocation file</b> of the account <b>to quit the Web Of Trust</b>.",
+      "REVOCATION_WITH_FILE_HELP": "To <b>permanently revoke</ b> a member account, please drag the revocation file in the box below, or click in the box to search for a file.",
       "REVOCATION_WALLET": "Revoke this account immediately",
       "REVOCATION_WALLET_HELP": "Requesting revocation of your identity causes <b>will revoke your membership</ b> (definitely for the associated pseudonym and public key). The account will no longer be able to produce a Universal Dividend.<br/>However, you can still use it as a simple wallet.",
       "REVOCATION_FILENAME": "revocation-{{uid}}-{{pubkey|formatPubkey}}-{{currency}}.txt",
@@ -569,6 +571,8 @@
     "POPUP_TITLE": "Error",
     "UNKNOWN_ERROR": "Unknown error",
     "CRYPTO_UNKNOWN_ERROR": "Your browser is not compatible with cryptographic features.",
+    "EQUALS_TO_PSEUDO": "Must be different from pseudonym",
+    "EQUALS_TO_SALT": "Must be different from secret identifier",
     "FIELD_REQUIRED": "This field is required.",
     "FIELD_TOO_SHORT": "Value is too short (min {{minLength]] characters).",
     "FIELD_TOO_SHORT_WITH_LENGTH": "This field value is too short.",
diff --git a/www/i18n/locale-en.json b/www/i18n/locale-en.json
index 7705e49db..b3ccb2ef6 100644
--- a/www/i18n/locale-en.json
+++ b/www/i18n/locale-en.json
@@ -233,6 +233,7 @@
       "SIG_STOCK": "Maximum number of certifications sent by a member",
       "SIG_PERIOD": "Minimum delay between 2 certifications sent by one and the same issuer.",
       "SIG_WINDOW": "Maximum delay before a certification will be treated",
+      "SIG_VALIDITY": "Lifetime of a certification that has been treated",
       "MS_WINDOW": "Maximum delay before a pending membership will be treated",
       "STEP_MAX": "Maximum distance between a newcomer and each referring members.",
       "WOT_RULES_DIVIDER": "Rules for web of trust",
@@ -534,7 +535,8 @@
       "RECOVER_ID": "Recover my password...",
       "RECOVER_ID_HELP": "If you have a <b>backup file of your identifiers</b>, you can find them by answering your personal questions correctly.",
       "REVOCATION_WITH_FILE" : "Rekoke my member account...",
-      "REVOCATION_WITH_FILE_HELP": "If you have <b>permanently lost your member account credentials (or if account security is compromised), you can use <b>the revocation file</b> of the account <b>to quit the Web Of Trust</b>.",
+      "REVOCATION_WITH_FILE_DESCRIPTION": "If you have <b>permanently lost your member account credentials (or if account security is compromised), you can use <b>the revocation file</b> of the account <b>to quit the Web Of Trust</b>.",
+      "REVOCATION_WITH_FILE_HELP": "To <b>permanently revoke</ b> a member account, please drag the revocation file in the box below, or click in the box to search for a file.",
       "REVOCATION_WALLET": "Revoke this account immediately",
       "REVOCATION_WALLET_HELP": "Requesting revocation of your identity causes <b>will revoke your membership</ b> (definitely for the associated pseudonym and public key). The account will no longer be able to produce a Universal Dividend.<br/>However, you can still use it as a simple wallet.",
       "REVOCATION_FILENAME": "revocation-{{uid}}-{{pubkey|formatPubkey}}-{{currency}}.txt",
@@ -569,6 +571,8 @@
     "POPUP_TITLE": "Error",
     "UNKNOWN_ERROR": "Unknown error",
     "CRYPTO_UNKNOWN_ERROR": "Your browser is not compatible with cryptographic features.",
+    "EQUALS_TO_PSEUDO": "Must be different from pseudonym",
+    "EQUALS_TO_SALT": "Must be different from secret identifier",
     "FIELD_REQUIRED": "This field is required.",
     "FIELD_TOO_SHORT": "Value is too short (min {{minLength]] characters).",
     "FIELD_TOO_SHORT_WITH_LENGTH": "This field value is too short.",
diff --git a/www/i18n/locale-es-ES.json b/www/i18n/locale-es-ES.json
index 92b7fd3e9..775675a8c 100644
--- a/www/i18n/locale-es-ES.json
+++ b/www/i18n/locale-es-ES.json
@@ -130,13 +130,16 @@
     "HISTORY_SETTINGS": "Operaciones de cuentas",
     "DISPLAY_UD_HISTORY": "Publicar los dividendos producidos ?",
     "AUTHENTICATION_SETTINGS": "Autenticación",
-    "AUTO_LOGOUT": "Desconexión automática",
-    "AUTO_LOGOUT_OPTION_NEVER": "Jamas",
-    "AUTO_LOGOUT_OPTION_SECONDS": "Después de {{value}} segundos",
-    "AUTO_LOGOUT_OPTION_MINUTE": "Después de {{value}} minuto",
-    "AUTO_LOGOUT_OPTION_MINUTES": "Después de {{value}} minutos",
-    "AUTO_LOGOUT_OPTION_HOUR": "Después de {{value}} hora",
-    "AUTO_LOGOUT_HELP": "Tiempo de inactividad antes de la desconexión",
+    "KEEP_AUTH": "Caducidad de la autenticación",
+    "KEEP_AUTH_HELP": "Definir cuándo se borra la autenticación de la memoria",
+    "KEEP_AUTH_OPTION": {
+      "NEVER": "Despues de cada operacion",
+      "SECONDS": "Después de {{value}} segundos de inactividad",
+      "MINUTE": "Después de {{value}} minuto de inactividad",
+      "MINUTES": "Después de {{value}} minutos de inactividad",
+      "HOUR": "Después de {{value}} hora de inactividad",
+      "ALWAYS": "Al final de la sesión"
+    },
     "REMEMBER_ME": "Recordarme",
     "REMEMBER_ME_HELP": "Siempre mantenerse conectado (no recomendado).",
     "PLUGINS_SETTINGS": "Extensiónes",
@@ -230,6 +233,7 @@
       "SIG_STOCK": "Número máximo de certificaciónes emitidas por miembros",
       "SIG_PERIOD": "Plazo mínimo de espera entre 2 certificaciónes sucesivas emitidas por la misma persona",
       "SIG_WINDOW": "Plazo límite para toma en cuenta de una certificación",
+      "SIG_VALIDITY": "Duración de una certificación que se ha tenido en cuenta.",
       "MS_WINDOW": "Plazo límite para toma en cuenta de una adhesión",
       "STEP_MAX": "Distancia máxima entre un nuevo entrante y los miembros referentes",
       "WOT_RULES_DIVIDER": "Regla de la red de confianza",
@@ -254,9 +258,12 @@
       "MEDIAN_TIME": "Hora de la blockchain",
       "LOADING_PEERS": "Carga de los nodos...",
       "NODE_ADDRESS": "Dirección del nodo",
+      "WS2PID": "ID :",
+      "POW_PREFIX": "Préfixe de preuve de travail :",
       "ENDPOINTS": {
         "BMAS": "Endpoint seguro (SSL)",
         "BMATOR": "TOR endpoint",
+        "WS2P": "WS2P endpoint",
         "ES_USER_API": "Nodo de datos Cesium+"
       }
     },
@@ -282,6 +289,7 @@
       "TITLE": "Nodo",
       "OWNER": "Propiedad de ",
       "SHOW_RAW_PEERING": "Ver la tarjeta de red",
+      "SHOW_RAW_CURRENT_BLOCK": "Ver el último bloque (formato sin formato)",
       "LAST_BLOCKS": "Bloques recientes",
       "KNOWN_PEERS": "Nodos conocidos :",
       "GENERAL_DIVIDER": "Informaciónes generales",
@@ -481,6 +489,8 @@
       "QUESTION_19": "Cuál fue el oficio de su abuelo ?",
       "RECOVER_ID": "Recuperar sus identificadores",
       "REVOCATION_WITH_FILE": "Revocar una identidad a partir de un fichero",
+      "REVOCATION_WITH_FILE_DESCRIPTION": "Si ha perdido las credenciales de su cuenta de miembro de forma permanente (o la seguridad de la cuenta se ve comprometida), puede usar <b>el archivo de revocación de la cuenta</b> para forzar publicación final de la web de confianza.",
+      "REVOCATION_WITH_FILE_HELP": "Para <b>revocar permanentemente</b> una cuenta de miembro, arrastre el archivo de revocación en el cuadro siguiente o haga clic en el cuadro para buscar un archivo.",
       "REVOCATION_FILENAME": "revocation-{{uid}}-{{pubkey|formatPubkey}}-{{currency}}.txt",
       "REVOCATION_WALLET": "Revocar esta identidad",
       "SAVE_ID": "Salvar sus identificadores",
@@ -513,6 +523,8 @@
     "POPUP_TITLE": "Error",
     "UNKNOWN_ERROR": "Error desconocida",
     "CRYPTO_UNKNOWN_ERROR": "Su navegador parece incompatible con las funcionalidades de cryptografía.",
+    "EQUALS_TO_PSEUDO": "Debe ser diferente del seudónimo.",
+    "EQUALS_TO_SALT": "Debe ser diferente del identificador secreto.",
     "FIELD_REQUIRED": "Campo obligatorio.",
     "FIELD_TOO_SHORT": "Valor demasiado corta.",
     "FIELD_TOO_SHORT_WITH_LENGTH": "Valor demasiado corta ({{minLength}} carácteres mín)",
diff --git a/www/i18n/locale-fr-FR.json b/www/i18n/locale-fr-FR.json
index 0f8116045..d863dda03 100644
--- a/www/i18n/locale-fr-FR.json
+++ b/www/i18n/locale-fr-FR.json
@@ -233,7 +233,7 @@
       "SIG_STOCK": "Nombre maximal de certifications émises par membre",
       "SIG_PERIOD": "Délai minimal d'attente entre 2 certifications successives émises par une même personne",
       "SIG_WINDOW": "Délai limite de prise en compte d'une certification",
-      "SIG_VALIDITY": "Durée de vie d'une certification qui a été pirse en compte",
+      "SIG_VALIDITY": "Durée de vie d'une certification qui a été prise en compte",
       "MS_WINDOW": "Délai limite de prise en compte d'une demande d'adhésion comme membre",
       "STEP_MAX": "Distance maximale, par les certifications, entre un nouvel entrant et les membres référents",
       "WOT_RULES_DIVIDER": "Règles de la toile de confiance",
@@ -535,7 +535,8 @@
       "RECOVER_ID": "Retrouver mon mot de passe...",
       "RECOVER_ID_HELP": "Si vous disposez d'un <b>fichier de sauvegarde de vos identifiants</b>, vous pouvez les retrouver en répondant correctement à vos questions personnelles.",
       "REVOCATION_WITH_FILE": "Révoquer mon compte membre...",
-      "REVOCATION_WITH_FILE_HELP": "Si vous avez <b>définitivement perdus vos identifiants</b> de compte membre (ou que la sécurité du compte est compromise), vous pouvez utiliser <b>le fichier de révocation</b> du compte pour <b>forcer sa sortie définitive de la toile de confiance</b>.",
+      "REVOCATION_WITH_FILE_DESCRIPTION": "Si vous avez <b>définitivement perdus vos identifiants</b> de compte membre (ou que la sécurité du compte est compromise), vous pouvez utiliser <b>le fichier de révocation</b> du compte pour <b>forcer sa sortie définitive de la toile de confiance</b>.",
+      "REVOCATION_WITH_FILE_HELP": "Pour <b>révoquer définitivement</b> un compte membre, veuillez glisser dans la zone ci-dessous votre fichier de révocation, ou bien cliquer dans la zone pour rechercher un fichier.",
       "REVOCATION_WALLET": "Révoquer immédiatement ce compte",
       "REVOCATION_WALLET_HELP": "Demander la révocation de votre identité entraine la <b>sortie de la toile de confiance</b> (définitive pour le pseudonyme et la clé publique associés). Le compte ne pourra plus produire de Dividende Universel.<br/>Vous pourrez toutefois encore vous y connecter, comme à un simple portefeuille.",
       "REVOCATION_FILENAME": "revocation-{{uid}}-{{pubkey|formatPubkey}}-{{currency}}.txt",
@@ -570,6 +571,8 @@
     "POPUP_TITLE": "Erreur",
     "UNKNOWN_ERROR": "Erreur inconnue",
     "CRYPTO_UNKNOWN_ERROR": "Votre navigateur ne semble pas compatible avec les fonctionnalités de cryptographie.",
+    "EQUALS_TO_PSEUDO": "Doit être différent du pseudonyme",
+    "EQUALS_TO_SALT": "Doit être différent de l'identifiant secret",
     "FIELD_REQUIRED": "Champ obligatoire.",
     "FIELD_TOO_SHORT": "Valeur trop courte.",
     "FIELD_TOO_SHORT_WITH_LENGTH": "Valeur trop courte ({{minLength}} caractères min)",
diff --git a/www/js/config.js b/www/js/config.js
index 653644f3f..12566a68a 100644
--- a/www/js/config.js
+++ b/www/js/config.js
@@ -12,54 +12,37 @@ angular.module("cesium.config", [])
 	"cacheTimeMs": 300000,
 	"fallbackLanguage": "en",
 	"rememberMe": true,
-	"showUDHistory": true,
-	"timeout": 30000,
+	"timeout": 300000,
 	"timeWarningExpireMembership": 5184000,
 	"timeWarningExpire": 7776000,
-	"keepAuthIlde": 600,
 	"useLocalStorage": true,
 	"useRelative": false,
-	"expertMode": false,
+	"expertMode": true,
 	"decimalCount": 2,
-	"httpsMode": false,
 	"shareBaseUrl": "https://g1.duniter.fr",
 	"helptip": {
-		"enable": true,
+		"enable": false,
 		"installDocUrl": {
 			"fr-FR": "https://duniter.org/fr/wiki/duniter/installer/",
-			"en": "https://duniter.org/en/wiki/duniter/install/"
+			"en": "https://github.com/duniter/duniter/blob/master/doc/install-a-node.md"
 		}
 	},
-	"license": {
-		"fr-FR": "license/license_g1-fr-FR",
-		"en": "license/license_g1-en"
-	},
 	"node": {
-		"host": "g1.duniter.org",
-		"port": "443"
+		"host": "g1-test.duniter.org",
+		"port": 443
 	},
 	"fallbackNodes": [
 		{
-			"host": "g1.duniter.fr",
-			"port": "443"
-		},
-		{
-			"host": "g1.duniter.org",
-			"port": "443"
-		}
-	],
-	"developers": [
-		{
-			"name": "Benoit Lavenier",
-			"pubkey": "38MEAZN68Pz1DTvT3tqgxx4yQP6snJCQhPqEFxbDk4aE"
+			"host": "g1-test.cgeek.fr",
+			"port": 443
 		}
 	],
 	"plugins": {
 		"es": {
 			"enable": true,
 			"askEnable": false,
-			"host": "g1.data.duniter.fr",
-			"port": "443",
+			"host": "g1-test.data.duniter.fr",
+			"port": 443,
 			"notifications": {
 				"txSent": true,
 				"txReceived": true,
@@ -70,7 +53,7 @@ angular.module("cesium.config", [])
 		}
 	},
 	"version": "0.18.2",
-	"build": "2017-10-14T08:51:13.055Z",
+	"build": "2017-10-20T16:07:02.760Z",
 	"newIssueUrl": "https://github.com/duniter/cesium/issues/new?labels=bug"
 })
 
diff --git a/www/js/controllers/join-controllers.js b/www/js/controllers/join-controllers.js
index 457e4d4b7..303bcf8f6 100644
--- a/www/js/controllers/join-controllers.js
+++ b/www/js/controllers/join-controllers.js
@@ -350,7 +350,11 @@ function JoinModalController($scope, $state, $interval, $timeout, Device, UIUtil
                 // Redirect to wallet
                 $state.go('app.view_wallet')
                   .then(function() {
-                    $scope.downloadRevocationRegistration();
+                    // Wait 12s (for wallet load)
+                    // then ask to download revocation file
+                    return $timeout(
+                      $scope.downloadRevocationRegistration,
+                      2000);
                   });
               })
               .catch(function(err) {
@@ -475,7 +479,7 @@ function JoinModalController($scope, $state, $interval, $timeout, Device, UIUtil
   };
 
   // TODO: remove auto add account when done
-  /*$timeout(function() {
+  $timeout(function() {
     //$scope.selectCurrency('g1');
     //$scope.selectAccountType('member');
     $scope.formData.username="azertypoi";
@@ -485,6 +489,6 @@ function JoinModalController($scope, $state, $interval, $timeout, Device, UIUtil
     $scope.formData.pseudo="azertypoi";
     //$scope.doNext();
     //$scope.doNext();
-  }, 400);*/
+  }, 400);
 }
 
diff --git a/www/js/directives.js b/www/js/directives.js
index ca8b00558..4871350e7 100644
--- a/www/js/directives.js
+++ b/www/js/directives.js
@@ -18,6 +18,24 @@ angular.module('cesium.directives', [])
       };
   })
 
+  // Add new different-to directive (need for form validation)
+  .directive("differentTo", function() {
+    return {
+      require: "?ngModel",
+      link: function(scope, element, attributes, ngModel) {
+        if (ngModel && attributes.differentTo) {
+          ngModel.$validators.differentTo = function(modelValue) {
+            return modelValue != scope.$eval(attributes.differentTo);
+          };
+
+          scope.$watch(attributes.differentTo, function() {
+            ngModel.$validate();
+          });
+        }
+      }
+    };
+  })
+
   .directive('numberFloat', function() {
     var NUMBER_REGEXP = new RegExp('^[0-9]+([.,][0-9]+)?$');
 
diff --git a/www/templates/join/modal_join_member.html b/www/templates/join/modal_join_member.html
index 4de17268f..a7b2e9e5e 100644
--- a/www/templates/join/modal_join_member.html
+++ b/www/templates/join/modal_join_member.html
@@ -168,12 +168,15 @@
                        ng-change="formDataChanged()"
                        ng-model="formData.username"
                        ng-minlength="8"
+                       different-to="formData.pseudo"
                        required>
+                <!-- different-to="formData.pseudo" -->
                 <input ng-if="showUsername"
                        name="username" type="text" placeholder="{{'LOGIN.SALT_HELP' | translate}}"
                        ng-change="formDataChanged()"
                        ng-model="formData.username"
                        ng-minlength="8"
+                       different-to="formData.pseudo"
                        required>
               </div>
               <div class="form-errors"
@@ -185,6 +188,9 @@
                 <div class="form-error" ng-message="required">
                   <span translate="ERROR.FIELD_REQUIRED"></span>
                 </div>
+                <div class="form-error" ng-message="differentTo">
+                  <span translate="ERROR.EQUALS_TO_PSEUDO"></span>
+                </div>
               </div>
 
               <!-- confirm salt -->
@@ -256,12 +262,14 @@
                        ng-model="formData.password"
                        ng-change="formDataChanged()"
                        ng-minlength="8"
+                       different-to="formData.username"
                        required>
                 <input ng-if="showPassword"
                        name="text" type="text" placeholder="{{'LOGIN.PASSWORD_HELP' | translate}}"
                        ng-model="formData.password"
                        ng-change="formDataChanged()"
                        ng-minlength="8"
+                       different-to="formData.username"
                        required>
               </div>
               <div class="form-errors"
@@ -273,6 +281,9 @@
                 <div class="form-error" ng-message="required">
                   <span translate="ERROR.FIELD_REQUIRED"></span>
                 </div>
+                <div class="form-error" ng-message="differentTo">
+                  <span translate="ERROR.EQUALS_TO_SALT"></span>
+                </div>
               </div>
 
               <!-- confirm password -->
diff --git a/www/templates/wallet/modal_security.html b/www/templates/wallet/modal_security.html
index ac05530bd..3e6b1ba92 100644
--- a/www/templates/wallet/modal_security.html
+++ b/www/templates/wallet/modal_security.html
@@ -51,7 +51,7 @@
                 <i class="item-image dark icon ion-person"></i>
                 <b class="ion-close icon-secondary dark" style="top: -8px; left: 39px; font-size: 12px;"></b>
                 <h2 translate>ACCOUNT.SECURITY.REVOCATION_WITH_FILE</h2>
-                <h4 class="gray" translate>ACCOUNT.SECURITY.REVOCATION_WITH_FILE_HELP</h4>
+                <h4 class="gray" translate>ACCOUNT.SECURITY.REVOCATION_WITH_FILE_DESCRIPTION</h4>
                 <i class="icon dark ion-ios-arrow-right"></i>
               </div>
             </div>
diff --git a/www/templates/wallet/slides/slides_revocation_file.html b/www/templates/wallet/slides/slides_revocation_file.html
index 435fdbf6f..dc31d88b3 100644
--- a/www/templates/wallet/slides/slides_revocation_file.html
+++ b/www/templates/wallet/slides/slides_revocation_file.html
@@ -1,5 +1,5 @@
 <ion-content class="has-header padding" >
-  <h3 translate>ACCOUNT.SECURITY.REVOKE_WITH_FILE</h3>
+  <p translate>ACCOUNT.SECURITY.REVOCATION_WITH_FILE_HELP</p>
 
   <div dropzone="recoverContent(file)">
     <div ng-if="!hasContent" onclick="angular.element(document.querySelector('#revocationFile'))[0].click();">
-- 
GitLab