security #4 recovery keyboard

Signed-off-by: Andrey Shovkoplyas <motor4ik@gmail.com>
This commit is contained in:
Andrey Shovkoplyas 2019-08-30 10:50:05 +03:00
parent 00bc2c48e0
commit d21ea6e8f6
No known key found for this signature in database
GPG Key ID: EAAB7C8622D860A4
6 changed files with 4 additions and 97 deletions

View File

@ -426,8 +426,7 @@
(fx/defn password-option-pressed
[{:keys [db] :as cofx}]
(if (= (get-in db [:hardwallet :flow]) :create)
#() ;;TODO with v1 flow
(multiaccounts.recover/navigate-to-recover-multiaccount-screen cofx)))
#())) ;;TODO with v1 flow
(defn settings-screen-did-load
[{:keys [db]}]

View File

@ -113,12 +113,6 @@
:confirm-button-text (i18n/label :recovery-confirm-phrase)
:on-accept #(re-frame/dispatch [::recover-multiaccount-confirmed])}}))))
(fx/defn navigate-to-recover-multiaccount-screen
[{:keys [db] :as cofx}]
(fx/merge cofx
{:db (dissoc db :multiaccounts/recover)}
(navigation/navigate-to-cofx :recover-multiaccount nil)))
(re-frame/reg-fx
::store-multiaccount
(fn [[id address password]]

View File

@ -31,7 +31,6 @@
(let [component (case view-id
:intro intro.views/intro
:multiaccounts multiaccounts.views/multiaccounts
:recover recover.views/recover
:new-group new-group
:contact-toggle-list contact-toggle-list
:group-chat-profile group-chat-profile

View File

@ -1,108 +1,26 @@
(ns status-im.ui.screens.multiaccounts.recover.views
(:require-macros [status-im.utils.views :refer [defview letsubs]
:as views])
(:require-macros [status-im.utils.views :refer [defview letsubs]])
(:require [re-frame.core :as re-frame]
[reagent.core :as reagent]
[status-im.ui.components.text-input.view :as text-input]
[status-im.ui.components.react :as react]
[status-im.ui.components.status-bar.view :as status-bar]
[status-im.ui.components.toolbar.view :as toolbar]
[status-im.multiaccounts.recover.core :as multiaccounts.recover]
[status-im.hardwallet.core :as hardwallet]
[status-im.i18n :as i18n]
[status-im.ui.screens.multiaccounts.recover.styles :as styles]
[status-im.ui.components.styles :as components.styles]
[status-im.utils.config :as config]
[status-im.utils.core :as utils.core]
[status-im.react-native.js-dependencies :as js-dependencies]
[status-im.ui.components.common.common :as components.common]
[status-im.utils.security :as security]
[status-im.utils.platform :as platform]
[clojure.string :as string]
[status-im.ui.components.action-button.styles :as action-button.styles]
[status-im.ui.components.action-button.action-button :as action-button]
[status-im.ui.components.colors :as colors]
[status-im.utils.gfycat.core :as gfy]
[status-im.utils.identicon :as identicon]
[status-im.ui.components.radio :as radio]
[status-im.ui.components.icons.vector-icons :as vector-icons]
[status-im.ui.screens.intro.views :as intro.views]
[status-im.utils.utils :as utils]
[status-im.constants :as constants]))
(defview passphrase-input [passphrase error warning]
(letsubs [input-ref (reagent/atom nil)]
[text-input/text-input-with-label
{:style styles/recovery-phrase-input
:height 92
:ref (partial reset! input-ref)
:label (i18n/label :t/recovery-phrase)
:accessibility-label :enter-12-words
:placeholder (i18n/label :t/enter-12-words)
:multiline true
:default-value passphrase
:auto-correct false
:on-change-text #(re-frame/dispatch [::multiaccounts.recover/passphrase-input-changed (security/mask-data %)])
:on-blur #(re-frame/dispatch [::multiaccounts.recover/passphrase-input-blured])
:error (cond error (i18n/label error)
warning (i18n/label warning))}]))
(defview password-input [password error on-submit-editing]
(views/letsubs [inp-ref (atom nil)]
{:component-will-update
(fn [_ [_ new-password]]
(when (and (string? new-password)
(string/blank? new-password)
@inp-ref)
(.clear @inp-ref)))}
[react/view {:style styles/password-input
:important-for-accessibility :no-hide-descendants}
[text-input/text-input-with-label
{:label (i18n/label :t/password)
:accessibility-label :enter-password
:placeholder (i18n/label :t/enter-password)
:default-value password
:auto-focus false
:on-change-text #(re-frame/dispatch [::multiaccounts.recover/password-input-changed (security/mask-data %)])
:on-blur #(re-frame/dispatch [::multiaccounts.recover/password-input-blured])
:secure-text-entry true
:error (when error (i18n/label error))
:on-submit-editing on-submit-editing
:ref #(reset! inp-ref %)}]]))
(defview recover []
(letsubs [recovered-multiaccount [:get-recover-multiaccount]]
(let [{:keys [passphrase password passphrase-valid? password-valid?
password-error passphrase-error passphrase-warning processing?]} recovered-multiaccount
valid-form? (and password-valid? passphrase-valid?)
disabled? (or (not recovered-multiaccount)
processing?
(not valid-form?))
sign-in #(re-frame/dispatch [::multiaccounts.recover/sign-in-button-pressed])]
[react/keyboard-avoiding-view {:style styles/screen-container}
[status-bar/status-bar]
[toolbar/toolbar nil toolbar/default-nav-back
[toolbar/content-title (i18n/label :t/sign-in-to-another)]]
[react/view styles/inputs-container
[passphrase-input (or passphrase "") passphrase-error passphrase-warning]
[password-input (or password "") password-error (when-not disabled? sign-in)]
(when platform/desktop?
[react/i18n-text {:style styles/recover-release-warning
:key :recover-multiaccount-warning}])]
[react/view components.styles/flex]
(if processing?
[react/view styles/processing-view
[react/activity-indicator {:animating true}]
[react/i18n-text {:style styles/sign-you-in
:key :sign-you-in}]]
[react/view {:style styles/bottom-button-container}
[react/view {:style components.styles/flex}]
[components.common/bottom-button
{:forward? true
:label (i18n/label :t/sign-in)
:disabled? disabled?
:on-press sign-in}]])])))
(defn bottom-sheet-view []
[react/view {:flex 1 :flex-direction :row}
[react/view action-button.styles/actions-list
@ -126,8 +44,7 @@
:content-height 130})
(defview enter-phrase []
(letsubs [{:keys [passphrase
processing?
(letsubs [{:keys [processing?
passphrase-error
words-count
next-button-disabled?]} [:get-recover-multiaccount]]
@ -164,6 +81,7 @@
:height 120
:multiline true
:auto-correct false
:keyboard-type "visible-password"
:container {:background-color :white
:min-width "50%"}
:style {:background-color :white

View File

@ -5,7 +5,6 @@
#{:login
:progress
:create-multiaccount
:recover-multiaccount
:recover-multiaccount-enter-phrase
:recover-multiaccount-select-storage
:recover-multiaccount-enter-password
@ -53,7 +52,6 @@
:progress
:keycard-recovery-intro
:create-multiaccount
:recover-multiaccount
:recover-multiaccount-enter-phrase
:recover-multiaccount-select-storage
:recover-multiaccount-enter-password

View File

@ -73,7 +73,6 @@
(def all-screens
{:login login/login
:progress progress/progress
:recover-multiaccount multiaccounts.recover/recover
:recover-multiaccount-enter-phrase multiaccounts.recover/enter-phrase
:recover-multiaccount-select-storage multiaccounts.recover/select-storage
:recover-multiaccount-enter-password multiaccounts.recover/enter-password