[fix 8829] fix wrong password behavior on login

fix #8829

Signed-off-by: yenda <eric@status.im>
This commit is contained in:
yenda 2019-09-03 13:09:19 +02:00
parent 6427061bad
commit ef36ece15b
No known key found for this signature in database
GPG Key ID: 0095623C0069DCE6
4 changed files with 40 additions and 43 deletions

View File

@ -432,7 +432,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
}
@ReactMethod
public void loginWithKeycard(final String whisperPrivateKey, final String encryptionPublicKey, final Callback callback) {
public void loginWithKeycard(final String whisperPrivateKey, final String encryptionPublicKey, final String configJSON, final Callback callback) {
Log.d(TAG, "loginWithKeycard");
if (!checkAvailability()) {
callback.invoke(false);
@ -442,7 +442,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
Runnable r = new Runnable() {
@Override
public void run() {
String result = Statusgo.loginWithKeycard(whisperPrivateKey, encryptionPublicKey);
String result = Statusgo.loginWithKeycard(whisperPrivateKey, encryptionPublicKey, configJSON);
callback.invoke(result);
}

View File

@ -1,20 +1,34 @@
(ns status-im.signals.core
(:require [status-im.chat.models.loading :as chat.loading]
[status-im.ethereum.subscriptions :as ethereum.subscriptions]
(:require [status-im.ethereum.subscriptions :as ethereum.subscriptions]
[status-im.i18n :as i18n]
[status-im.mailserver.core :as mailserver]
[status-im.multiaccounts.login.core :as login]
[status-im.multiaccounts.model :as multiaccounts.model]
[status-im.node.core :as node]
[status-im.pairing.core :as pairing]
[status-im.transport.filters.core :as transport.filters]
[status-im.transport.message.core :as transport.message]
[status-im.utils.fx :as fx]
[status-im.utils.types :as types]
[taoensso.timbre :as log]
[status-im.multiaccounts.login.core :as login]))
[taoensso.timbre :as log]))
(fx/defn status-node-started
[{db :db :as cofx} event]
(login/multiaccount-login-success cofx))
[{db :db :as cofx} {:keys [error]}]
(if error
{:db (-> db
(update :multiaccounts/login dissoc :processing)
(assoc-in [:multiaccounts/login :error]
;; NOTE: the only currently known error is
;; "file is not a database" which occurs
;; when the user inputs the wrong password
;; if that is the error that is found
;; we show the i18n label for wrong password
;; to the user
;; in case of an unknown error we show the
;; error
(if (= error "file is not a database")
(i18n/label :t/wrong-password)
error)))}
(login/multiaccount-login-success cofx)))
(fx/defn summary
[{:keys [db] :as cofx} peers-summary]

View File

@ -1,23 +1,21 @@
(ns status-im.ui.screens.multiaccounts.login.views
(:require-macros [status-im.utils.views :refer [defview letsubs]])
(:require [clojure.string :as string]
[status-im.ui.components.colors :as colors]
[status-im.ui.screens.multiaccounts.styles :as ast]
[status-im.ui.components.text-input.view :as text-input]
[status-im.ui.components.status-bar.view :as status-bar]
[status-im.ui.components.toolbar.view :as toolbar]
[status-im.ui.components.checkbox.view :as checkbox]
[status-im.ui.components.toolbar.actions :as act]
[status-im.ui.screens.multiaccounts.login.styles :as styles]
[status-im.ui.components.react :as react]
(:require [re-frame.core :as re-frame]
[status-im.i18n :as i18n]
[status-im.utils.utils :as utils]
[status-im.ui.components.react :as components]
[status-im.ui.components.checkbox.view :as checkbox]
[status-im.ui.components.colors :as colors]
[status-im.ui.components.common.common :as components.common]
[status-im.ui.components.react :as react]
[status-im.ui.components.status-bar.view :as status-bar]
[status-im.ui.components.text-input.view :as text-input]
[status-im.ui.components.toolbar.actions :as act]
[status-im.ui.components.toolbar.view :as toolbar]
[status-im.ui.screens.chat.photos :as photos]
[re-frame.core :as re-frame]
[status-im.ui.screens.multiaccounts.login.styles :as styles]
[status-im.ui.screens.multiaccounts.styles :as ast]
[status-im.utils.platform :as platform]
[status-im.utils.security :as security]))
[status-im.utils.security :as security]
[status-im.utils.utils :as utils])
(:require-macros [status-im.utils.views :refer [defview letsubs]]))
(defn login-toolbar [can-navigate-back?]
[toolbar/toolbar
@ -31,21 +29,6 @@
(.blur password-text-input)
(re-frame/dispatch [:multiaccounts.login.ui/password-input-submitted]))
(defn- error-key [error]
;; TODO Improve selection logic when status-go provide an error code
;; see https://github.com/status-im/status-go/issues/278
(cond
(string/starts-with? error "there is no running node")
:t/node-unavailable
(or
(string/starts-with? error "cannot retrieve a valid key")
(string/starts-with? error "could not decrypt key"))
:t/wrong-password
:else
:t/unknown-status-go-error))
(defn multiaccount-login-badge [photo-path name public-key]
[react/view styles/login-badge
[photos/photo photo-path {:size styles/login-badge-image-size}]
@ -83,7 +66,7 @@
(security/mask-data %)])
(re-frame/dispatch [:set-in [:multiaccounts/login :error] ""]))
:secure-text-entry true
:error (when (not-empty error) (i18n/label (error-key error)))}]]
:error (when (not-empty error) error)}]]
(when-not platform/desktop?
;; saving passwords is unavailable on Desktop
@ -101,7 +84,7 @@
[react/text (i18n/label :t/save-password)]]))]]
(when processing
[react/view styles/processing-view
[components/activity-indicator {:animating true}]
[react/activity-indicator {:animating true}]
[react/i18n-text {:style styles/processing :key :processing}]])
[react/view {:style styles/bottom-button-container}
[components.common/button

View File

@ -3,6 +3,6 @@
"owner": "status-im",
"repo": "status-go",
"version": "develop",
"commit-sha1": "1a47893e75bccc99af3ce4b2c7fbedf6481dae6a",
"src-sha256": "1mcdm48bs9wz2nndicss3kia0rm4zk861a7qv6qaxjw12y6n8man"
"commit-sha1": "42199e682fdf90a82e59451a58b9ae07749a8e12",
"src-sha256": "11ykhcx057l6s0zg5cansv5x8728k0j86ygsj12m8ax86xjkdzyc"
}