reset password after 3 wrong attempts & close transactions screen if there are no transactions (#371, #372)
This commit is contained in:
parent
64c8e666ff
commit
bda65d6f1b
|
@ -14,5 +14,5 @@ android {
|
|||
|
||||
dependencies {
|
||||
compile 'com.facebook.react:react-native:+'
|
||||
compile(group: 'status-im', name: 'status-go', version: '0.1.2', ext: 'aar')
|
||||
compile(group: 'status-im', name: 'status-go', version: 'tx-complete-updates-3', ext: 'aar')
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
<artifactItem>
|
||||
<groupId>status-im</groupId>
|
||||
<artifactId>status-go-ios</artifactId>
|
||||
<version>0.1.2</version>
|
||||
<version>tx-complete-updates-3</version>
|
||||
<type>zip</type>
|
||||
<overWrite>true</overWrite>
|
||||
<outputDirectory>./</outputDirectory>
|
||||
|
|
|
@ -7,12 +7,10 @@
|
|||
[org.clojure/clojurescript "1.9.229"]
|
||||
[reagent "0.5.1" :exclusions [cljsjs/react]]
|
||||
[re-frame "0.7.0"]
|
||||
[prismatic/schema "1.0.4"]
|
||||
[natal-shell "0.3.0"]
|
||||
[com.andrewmcveigh/cljs-time "0.4.0"]
|
||||
[tailrecursion/cljs-priority-map "1.2.0"]
|
||||
[com.taoensso/timbre "4.7.4"]
|
||||
[org.clojure/test.check "0.9.0"]]
|
||||
[com.taoensso/timbre "4.7.4"]]
|
||||
:plugins [[lein-cljsbuild "1.1.4"]
|
||||
[lein-figwheel "0.5.0-2"]]
|
||||
:clean-targets ["target/" "index.ios.js" "index.android.js"]
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
(ns status-im.db
|
||||
(:require [schema.core :as s :include-macros true]
|
||||
[status-im.components.react :refer [animated]]
|
||||
(:require [status-im.components.react :refer [animated]]
|
||||
[status-im.components.animation :as anim]
|
||||
[status-im.constants :refer [console-chat-id]]))
|
||||
|
||||
;; schema of app-db
|
||||
(def schema {:greeting s/Str})
|
||||
|
||||
;; initial state of app-db
|
||||
(def app-db {:identity-password "replace-me-with-user-entered-password"
|
||||
:identity "me"
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
(ns status-im.handlers
|
||||
(:require
|
||||
[re-frame.core :refer [after dispatch dispatch-sync debug]]
|
||||
[schema.core :as s :include-macros true]
|
||||
[status-im.db :refer [app-db schema]]
|
||||
[status-im.db :refer [app-db]]
|
||||
[status-im.data-store.core :as data-store]
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.utils.crypt :refer [gen-random-bytes]]
|
||||
|
@ -109,6 +108,7 @@
|
|||
(let [{:keys [type event]} (t/json->clj event-str)]
|
||||
(case type
|
||||
"transaction.queued" (dispatch [:transaction-queued event])
|
||||
"transaction.failed" (dispatch [:transaction-failed event])
|
||||
"node.started" (log/debug "Event *node.started* received")
|
||||
"module.initialized" (dispatch [:status-module-initialized!])
|
||||
(log/debug "Event " type " not handled"))))))
|
||||
|
|
|
@ -23,7 +23,11 @@
|
|||
|
||||
(defmethod nav/preload-data! :confirm
|
||||
[{:keys [transactions-queue] :as db} _]
|
||||
(assoc db :transactions transactions-queue))
|
||||
(-> db
|
||||
(assoc :transactions transactions-queue
|
||||
:wrong-password-counter 0
|
||||
:wrong-password? false)
|
||||
(assoc-in [:confirm-transactions :password] 0)))
|
||||
|
||||
(defn on-unlock
|
||||
[ids password previous-view-id]
|
||||
|
@ -69,6 +73,9 @@
|
|||
(update :transactions-queue #(apply dissoc % hashes)))))
|
||||
|
||||
(register-handler ::remove-transaction
|
||||
(after (fn [{:keys [transactions]}]
|
||||
(when-not (seq transactions)
|
||||
(dispatch [:navigate-back]))))
|
||||
(fn [db [_ hash]]
|
||||
(-> db
|
||||
(update :transactions dissoc hash)
|
||||
|
@ -122,19 +129,11 @@
|
|||
|
||||
(register-handler :transaction-completed
|
||||
(u/side-effect!
|
||||
(fn [{:keys [transactions command->chat]} [_ {:keys [id response previous-view-id]}]]
|
||||
(fn [{:keys [transactions]} [_ {:keys [id response previous-view-id]}]]
|
||||
(let [{:keys [hash error] :as parsed-response} (t/json->clj response)
|
||||
{:keys [message-id]} (transactions id)]
|
||||
(log/debug :parsed-response parsed-response)
|
||||
(if (and error (string? error) (not (s/blank? error)))
|
||||
;; todo: revisit this
|
||||
;; currently transaction is removed after attempt
|
||||
;; to complete it with wrong password
|
||||
(do
|
||||
(dispatch [::remove-transaction id])
|
||||
(dispatch [:set :wrong-password? true])
|
||||
(when-let [chat-id (get command->chat message-id)]
|
||||
(dispatch [:clear-command chat-id message-id])))
|
||||
(when-not (and error (string? error) (not (s/blank? error)))
|
||||
(if message-id
|
||||
(do (dispatch [::add-transactions-hash {:id id
|
||||
:hash hash
|
||||
|
@ -172,3 +171,27 @@
|
|||
(when (and pending-message id hash)
|
||||
(dispatch [::send-pending-message message-id hash])
|
||||
(dispatch [::remove-transaction id]))))))
|
||||
|
||||
(def wrong-password-code "2")
|
||||
|
||||
(register-handler :transaction-failed
|
||||
(u/side-effect!
|
||||
(fn [_ [_ {:keys [id message_id error_code]}]]
|
||||
(if-not (= wrong-password-code error_code)
|
||||
(do (when message_id
|
||||
(dispatch [::remove-pending-message message_id]))
|
||||
(dispatch [::remove-transaction id]))
|
||||
(dispatch [:set-wrong-password!])))))
|
||||
|
||||
(def attempts-limit 3)
|
||||
|
||||
(register-handler :set-wrong-password!
|
||||
(after (fn [{:keys [wrong-password-counter]}]
|
||||
(when (>= wrong-password-counter attempts-limit)
|
||||
(dispatch [:set :wrong-password? false])
|
||||
(dispatch [:set :wrong-password-counter 0])
|
||||
(dispatch [:set-in [:confirm-transactions :password] ""]))))
|
||||
(fn [db]
|
||||
(-> db
|
||||
(assoc :wrong-password? true)
|
||||
(update :wrong-password-counter (fnil inc 0)))))
|
||||
|
|
Loading…
Reference in New Issue