[#7908] [#7909] handle wrong pairing password

* show 'invalid pairing password' on failed pairing
* wrap view into scroll view

Signed-off-by: Dmitry Novotochinov <dmitry.novot@gmail.com>
This commit is contained in:
Dmitry Novotochinov 2019-04-15 19:46:41 +03:00
parent 08d7db80af
commit ebccb8e020
No known key found for this signature in database
GPG Key ID: 43D1DAF5AD39C927
3 changed files with 45 additions and 25 deletions

View File

@ -145,7 +145,8 @@
(set-setup-step card-state)
(if (= :pre-init card-state)
(navigation/navigate-to-cofx :hardwallet-setup nil)
(navigation/navigate-to-cofx :hardwallet-authentication-method nil))
(when-not (= :not-paired card-state)
(navigation/navigate-to-cofx :hardwallet-authentication-method nil)))
(when (= card-state :blank)
(show-no-keycard-applet-alert))
(when (= card-state :account)
@ -539,9 +540,15 @@
(dispatch-event :hardwallet/pair)
(navigation/navigate-to-cofx :hardwallet-connect nil)))))
(fx/defn pair [cofx]
(let [{:keys [password]} (get-in cofx [:db :hardwallet :secrets])]
{:hardwallet/pair {:password password}}))
(fx/defn pair
[{:keys [db] :as cofx}]
(let [{:keys [password]} (get-in cofx [:db :hardwallet :secrets])
card-connected? (get-in db [:hardwallet :card-connected?])]
(if card-connected?
{:hardwallet/pair {:password password}}
(fx/merge cofx
{:db (assoc-in db [:hardwallet :on-card-connected] :hardwallet/pair)}
(navigation/navigate-to-cofx :hardwallet-connect nil)))))
(fx/defn return-back-from-nfc-settings [{:keys [db]}]
(when (= :hardwallet-connect (:view-id db))
@ -985,9 +992,13 @@
(fx/defn on-pairing-error
[{:keys [db] :as cofx} {:keys [error code]}]
(log/debug "[hardwallet] pairing error: " error)
(let [setup-step (get-in db [:hardwallet :setup-step])]
(fx/merge cofx
{:db (assoc-in db [:hardwallet :setup-error] error)}
(process-error code)))
{:db (-> db
(assoc-in [:hardwallet :setup-error] (i18n/label :t/invalid-pairing-password))
(assoc-in [:hardwallet :on-card-connected] nil))}
(when (not= setup-step :enter-pair-code)
(process-error code)))))
(fx/defn on-generate-mnemonic-success
[{:keys [db]} mnemonic]

View File

@ -206,7 +206,9 @@
(defview enter-pair-code []
(letsubs [pair-code [:hardwallet-pair-code]
error [:hardwallet-setup-error]
width [:dimensions/window-width]]
[react/scroll-view
[react/view styles/enter-pair-code-container
[react/view styles/enter-pair-code-title-container
[react/view
@ -214,6 +216,12 @@
(i18n/label :t/enter-pair-code)]
[react/text {:style styles/enter-pair-code-explanation-text}
(i18n/label :t/enter-pair-code-description)]]
(when error
[react/view
[react/text {:style {:font-weight "700"
:padding-top 10
:color colors/red}}
error]])
[react/view (styles/enter-pair-code-input-container width)
[text-input/text-input-with-label
{:on-change-text #(re-frame/dispatch [:hardwallet.ui/pair-code-input-changed %])
@ -224,7 +232,7 @@
[components.common/bottom-button
{:on-press #(re-frame/dispatch [:hardwallet.ui/pair-code-next-button-pressed])
:disabled? (empty? pair-code)
:forward? true}]]]]))
:forward? true}]]]]]))
(defn- card-with-button-view
[{:keys [text-label button-label button-container-style on-press show-icon?]}]

View File

@ -903,6 +903,7 @@
"help": "help",
"help-capitalized": "Help",
"pairing-card": "Pairing card",
"invalid-pairing-password": "Invalid pairing password",
"complete-exclamation": "Complete!",
"complete-hardwallet-setup": "This card is now an essential part your account security. Transactions can't be sent without it.",
"okay": "Okay",