diff --git a/www/i18n/locale-en.json b/www/i18n/locale-en.json index 60f96d5295b58c93687448c9df47f183cf36e09b..73bdfd93c2442b6f19e154b8e72428f8e20da594 100644 --- a/www/i18n/locale-en.json +++ b/www/i18n/locale-en.json @@ -25,6 +25,7 @@ "BTN_DELETE": "Delete", "BTN_ADD": "Add", "BTN_SEARCH": "Search", + "BTN_CONTINUE": "Continue", "NO_ACCOUNT_QUESTION": "No a member ? Register now !", "SEARCH_NO_RESULT": "No result found", "LOADING": "Loading...", @@ -324,7 +325,9 @@ "CERTIFY_RULES_TITLE_UID": "Certify {{uid}}", "CERTIFY_RULES": "<b>Security warning:</b><br/><br/><b class=\"assertive\">Don't certify an account</b> if you believe that: <ul><li>1.) the issuers identity might be faked.<li>2.) the issuer already has another certified account.<li>3.) the issuer purposely or carelessly violates rule 1 or 2 (he certifies faked or double accounts).</ul></small><br/>Are you sure you want to certify this identity ?", "TRANSFER": "<b>Transfer summary:</b><br/><br/><ul><li> - From: <b>{{from}}</b></li><li> - To: <b>{{to}}</b></li><li> - Amount: <b>{{amount}} {{unit}}</b></li><li> - Comment: <i>{{comment}}</i></li></ul><br/><b>Are-you sure you want to do this transfer ?</b>", - "MEMBERSHIP_OUT": "<b>Warning</b>:<br/>You are going to terminate your membership. This operation is irreversible<br/></br/><b>Are you sure you want to continue ?</b>" + "MEMBERSHIP_OUT": "<b>Warning</b>:<br/>You are going to terminate your membership. This operation is irreversible<br/></br/><b>Are you sure you want to continue ?</b>", + "LOGIN_UNUSED_WALLET": "You are logged into an account that seems <b>inactive</b>.<br/><br/>If this account does not match yours, it's probably a <b>typing error</b> when sign in.<br/><br/><b>Would you still continue with this account?</b>", + "LOGIN_UNUSED_WALLET_TITLE": "Typing error ?" }, "HELP": { "TITLE": "Online help", diff --git a/www/i18n/locale-fr-FR.json b/www/i18n/locale-fr-FR.json index 3f1fa24cfe78c1d312a776a965caef2f1237958a..970eb23fac1f196d37f0c2bda62b2753dc015f59 100644 --- a/www/i18n/locale-fr-FR.json +++ b/www/i18n/locale-fr-FR.json @@ -25,6 +25,7 @@ "BTN_DELETE": "Supprimer", "BTN_ADD": "Ajouter", "BTN_SEARCH": "Recherche", + "BTN_CONTINUE": "Continuer", "NO_ACCOUNT_QUESTION": "Pas de encore membre ? Créer un compte !", "SEARCH_NO_RESULT": "Aucun résultat trouvé", "LOADING": "Veuillez patienter...", @@ -324,7 +325,9 @@ "CERTIFY_RULES_TITLE_UID": "Certifier {{uid}}", "CERTIFY_RULES": "<b>Avertissement de sécurité :</b><br/><br/><b class=\"assertive\">Ne pas certifier</b> un compte si vous pensez que :<ul><li>1.) il ne correspond pas à une personne physique vivante.<li>2.) son propriétaire possède un autre compte déjà certifié.<li>3.) son propriétaire viole (volontairement ou non) la règle 1 ou 2 (par exemple en certifiant des comptes factices ou en double).</ul><br/><b>Etes-vous sûr de vouloir néanmoins certifier cette identité ?</b>", "TRANSFER": "<b>Récapitulatif du virement</b> :<br/><br/><ul><li> - De : {{from}}</li><li> - A : <b>{{to}}</b></li><li> - Montant : <b>{{amount}} {{unit}}</b></li><li> - Commentaire : <i>{{comment}}</i></li></ul><br/><b>Etes-vous sûr de vouloir effectuer ce virement ?</b>", - "MEMBERSHIP_OUT": "<b>Avertissement</b> :<br/>Vous allez résilier votre adhésion comme membre. Cette opération est <b>irréversible</b>.<br/></br/><b>Etes-vous sûr de vouloir continuer ?</b>" + "MEMBERSHIP_OUT": "<b>Avertissement</b> :<br/>Vous allez résilier votre adhésion comme membre. Cette opération est <b>irréversible</b>.<br/></br/><b>Etes-vous sûr de vouloir continuer ?</b>", + "LOGIN_UNUSED_WALLET": "Vous êtes connecté sur un compte qui parait <b>inactif</b>.<br/><br/>Si ce compte ne correspond pas au votre, il s'agit probablement d'une <b>erreur de saisie</b> de vos identifiants de connexion.<br/></br/><b>Voulez-vous néanmoins continuer avec ce compte ?</b>", + "LOGIN_UNUSED_WALLET_TITLE": "Erreur de saisie ?" }, "HELP": { "TITLE": "Aide en ligne", diff --git a/www/js/controllers/app-controllers.js b/www/js/controllers/app-controllers.js index b9e78119746e7dc4e7340801882a41874cee70f0..225a9aaf71a8a20df5a40cf3a95207c7b99dcb6d 100644 --- a/www/js/controllers/app-controllers.js +++ b/www/js/controllers/app-controllers.js @@ -133,6 +133,22 @@ function AppController($scope, $rootScope, $state, $ionicSideMenuDelegate, $q, $ // Login and load wallet $scope.loadWallet = function(rejectIfError) { + + // Warn if wallet has been never used - see #167 + var alertIfUnusedWallet = function() { + if (Wallet.isNeverUsed()) { + UIUtils.alert.confirm('CONFIRM.LOGIN_UNUSED_WALLET', + 'CONFIRM.LOGIN_UNUSED_WALLET_TITLE', { + okText: 'COMMON.BTN_CONTINUE' + }) + .then(function (confirm) { + if (!confirm) { + $scope.logout().then($scope.loadWallet); + } + }); + } + }; + return $q(function(resolve, reject){ if (!Wallet.isLogin()) { @@ -142,6 +158,7 @@ function AppController($scope, $rootScope, $state, $ionicSideMenuDelegate, $q, $ $rootScope.viewFirstEnter = false; Wallet.loadData() .then(function(walletData){ + alertIfUnusedWallet(); $rootScope.walletData = walletData; resolve(walletData); }) @@ -162,6 +179,7 @@ function AppController($scope, $rootScope, $state, $ionicSideMenuDelegate, $q, $ else if (!Wallet.data.loaded) { Wallet.loadData() .then(function(walletData){ + alertIfUnusedWallet(); $rootScope.walletData = walletData; resolve(walletData); }) @@ -226,11 +244,11 @@ function AppController($scope, $rootScope, $state, $ionicSideMenuDelegate, $q, $ // Logout $scope.logout = function() { UIUtils.loading.show(); - Wallet.logout() + return Wallet.logout() .then(function() { $ionicSideMenuDelegate.toggleLeft(); $ionicHistory.clearHistory(); - $ionicHistory.clearCache() + return $ionicHistory.clearCache() .then(function() { UIUtils.loading.hide(); $state.go('app.home'); diff --git a/www/js/controllers/currency-controllers.js b/www/js/controllers/currency-controllers.js index 8d7ef0c8165c704fd847afb816dc2b8c1f1d8219..6ad7d296ad7d8d4a7412f0bb95586ef68b3d25cd 100644 --- a/www/js/controllers/currency-controllers.js +++ b/www/js/controllers/currency-controllers.js @@ -147,7 +147,8 @@ function CurrencyViewController($scope, $q, $translate, $timeout, BMA, UIUtils, $timeout(function() { console.debug("Updating UI Peers"); $scope.peers = data.peers; - }, 100); + $scope.loadingPeers = csNetwork.isBusy(); + }, 1000); }); $scope.$on('$destroy', function(){ csNetwork.close(); @@ -240,16 +241,6 @@ function CurrencyViewController($scope, $q, $translate, $timeout, BMA, UIUtils, }); }; - $scope.waitLoadingPeersFinish = function() { - "use strict"; - if (csNetwork.isBusy()) { - $timeout($scope.waitLoadingPeersFinish, 500); - } - else { - $scope.loadingPeers = false; - } - }; - $scope.refresh = function() { UIUtils.loading.show(); diff --git a/www/js/controllers/login-controllers.js b/www/js/controllers/login-controllers.js index ed7778eeb73a3c293a76e22577732ab94a3b474f..f5fb0e0efcbad2c05dcfc289e4c714c0a51e25eb 100644 --- a/www/js/controllers/login-controllers.js +++ b/www/js/controllers/login-controllers.js @@ -13,6 +13,8 @@ function LoginModalController($scope, $timeout, CryptoUtils, UIUtils, Modals, cs rememberMe: csSettings.data.rememberMe }; $scope.showValues = false; + $scope.showPubkeyButton = false; + $scope.autoComputePubkey = ionic.Platform.grade.toLowerCase()==='a'; // Login form submit $scope.doLogin = function() { @@ -31,29 +33,44 @@ function LoginModalController($scope, $timeout, CryptoUtils, UIUtils, Modals, cs $scope.formDataChanged = function() { $scope.computing=false; - $scope.pubkey = ''; - /*if (!$scope.isDeviceEnable()){ + $scope.pubkey = null; + if ($scope.autoComputePubkey && $scope.formData.username && $scope.formData.password) { $scope.showPubkey(); - }*/ + } + else { + $scope.showPubkeyButton = $scope.formData.username && $scope.formData.password; + } }; $scope.$watch('formData.username', $scope.formDataChanged, true); $scope.$watch('formData.password', $scope.formDataChanged, true); $scope.showPubkey = function() { $scope.computing=true; - CryptoUtils.connect($scope.formData.username, $scope.formData.password).then( - function(keypair) { - $scope.pubkey = CryptoUtils.util.encode_base58(keypair.signPk); - $scope.computing=false; - } - ) - .catch(function(err) { - $scope.pubkey = ''; - $scope.computing=false; - UIUtils.loading.hide(); - console.error('>>>>>>>' , err); - UIUtils.alert.error('ERROR.CRYPTO_UNKNOWN_ERROR'); - }); + $scope.showPubkeyButton = false; + $scope.pubkey = ''; + $timeout(function() { + var salt = $scope.formData.username; + var pwd = $scope.formData.password; + CryptoUtils.connect(salt, pwd).then( + function (keypair) { + // form has changed: retry + if (salt !== $scope.formData.username || pwd !== $scope.formData.password) { + $scope.showPubkey(); + } + else { + $scope.pubkey = CryptoUtils.util.encode_base58(keypair.signPk); + $scope.computing = false; + } + } + ) + .catch(function (err) { + $scope.pubkey = ''; + $scope.computing = false; + UIUtils.loading.hide(); + console.error('>>>>>>>', err); + UIUtils.alert.error('ERROR.CRYPTO_UNKNOWN_ERROR'); + }); + }, 500); }; $scope.showJoinModal = function() { diff --git a/www/js/services/utils-services.js b/www/js/services/utils-services.js index 03ef04a6ce6137805b3ba1c797de88b8fadda3b2..b57b7d5199d97cf8c0bba2cec4fd7b4aab578445 100644 --- a/www/js/services/utils-services.js +++ b/www/js/services/utils-services.js @@ -71,19 +71,26 @@ angular.module('cesium.utils.services', ['ngResource']) }); } - function askConfirm(message, title) { - if (!title) { - title = 'CONFIRM.POPUP_TITLE'; - } + function askConfirm(message, title, options) { + title = title || 'CONFIRM.POPUP_TITLE'; + + var defaultOptions = { + cssClass: 'confirm', + cancelText: 'COMMON.BTN_CANCEL', + okText: 'COMMON.BTN_OK' + }; + + options = options ? angular.merge(defaultOptions, options) : defaultOptions; + return $q(function(resolve, reject) { - $translate([message, title, 'COMMON.BTN_CANCEL', 'COMMON.BTN_OK']) + $translate([message, title, options.cancelText, options.okText]) .then(function (translations) { $ionicPopup.confirm({ template: translations[message], - cssClass: 'confirm', + cssClass: options.cssClass, title: translations[title], - cancelText: translations['COMMON.BTN_CANCEL'], - okText: translations['COMMON.BTN_OK'] + cancelText: translations[options.cancelText], + okText: translations[options.okText] }) .then(function(res) { resolve(res); diff --git a/www/js/services/wallet-services.js b/www/js/services/wallet-services.js index de2d1768b44da011f9820d449d65f9d3ef7c1a6b..48e40e727bdfbcb224d38e17f91fa2b6a9ebe480 100644 --- a/www/js/services/wallet-services.js +++ b/www/js/services/wallet-services.js @@ -160,6 +160,13 @@ angular.module('cesium.wallet.services', ['ngResource', 'ngApi', 'cesium.bma.ser return !!data.pubkey; }, + isNeverUsed = function() { + return !data.pubkey || + (!data.isMember && + !data.tx.history.length && + !data.tx.pendings.length); + }, + // If connected and same pubkey isUserPubkey = function(pubkey) { return isLogin() && data.pubkey === pubkey; @@ -1188,6 +1195,7 @@ angular.module('cesium.wallet.services', ['ngResource', 'ngApi', 'cesium.bma.ser login: login, logout: logout, isLogin: isLogin, + isNeverUsed: isNeverUsed, isUserPubkey: isUserPubkey, getData: getData, loadData: loadData, diff --git a/www/templates/modal_login.html b/www/templates/modal_login.html index 285e7bb5567035f9bb500c51f3b414c26eae01ee..d431d66c3e2cfc1ef3eaa11c941b062521baba70 100644 --- a/www/templates/modal_login.html +++ b/www/templates/modal_login.html @@ -87,14 +87,15 @@ <!-- Show public key --> <div class="item item-button-right left"> - <span class="input-label" translate>COMMON.PUBKEY</span> + <span ng-if="formData.username && formData.password" + class="input-label" translate>COMMON.PUBKEY</span> <a class="button button-light button-small ink animate-if" ng-click="showPubkey()" - ng-if="!(pubkey || computing || !formData.username || !formData.password)" + ng-if="showPubkeyButton" > {{'COMMON.BTN_SHOW_PUBKEY' | translate}} </a> - <h3 class="gray text-no-wrap" ng-if="pubkey"> + <h3 class="gray text-no-wrap" ng-if="!computing"> {{pubkey}} </h3> <h3 ng-if="computing">