Skip to content

Commit

Permalink
Use auth-switched-on-fx in both onboarding and settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitaliy Vlasov committed Sep 9, 2019
1 parent c179d9d commit 6e61beb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
18 changes: 16 additions & 2 deletions src/status_im/biometric_auth/core.cljs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
(ns status-im.biometric-auth.core
(:require [re-frame.core :as re-frame]
[taoensso.timbre :as log]
[status-im.utils.platform :as platform]
[status-im.i18n :as i18n]
[status-im.utils.fx :as fx]
[status-im.utils.utils :as utils]
[status-im.ui.components.colors :as colors]
[status-im.native-module.core :as status]
[status-im.react-native.js-dependencies :as rn]))
Expand Down Expand Up @@ -66,7 +68,9 @@
(defn- do-get-supported [callback]
(-> (.isSupported rn/touchid)
(.then #(callback (or (keyword %) android-default-support)))
(.catch #(callback nil))))
(.catch #(do
(log/info "Error while getting biometric auth status:" %)
(callback nil)))))

(defn get-supported [callback]
(cond platform/ios? (do-get-supported callback)
Expand All @@ -90,4 +94,14 @@
(re-frame/reg-fx
:biometric-auth/authenticate
(fn [[cb options]]
(authenticate #(cb %) options)))
(authenticate #(cb %) options)))

(defn auth-switched-on-fx [cofx]
(authenticate-fx
cofx
(fn [{:keys [bioauth-success bioauth-message]}]
(when bioauth-success
(re-frame/dispatch [:multiaccounts.ui/switch-biometric-auth true]))
(when bioauth-message
(utils/show-popup (i18n/label :t/biometric-auth-reason-verify) bioauth-message)))
{:reason (i18n/label :t/biometric-auth-reason-verify)}))
11 changes: 2 additions & 9 deletions src/status_im/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[status-im.multiaccounts.logout.core :as multiaccounts.logout]
[status-im.multiaccounts.recover.core :as multiaccounts.recover]
[status-im.multiaccounts.update.core :as multiaccounts.update]
[status-im.biometric-auth.core :as biomentric-auth]
[status-im.biometric-auth.core :as biometric-auth]
[status-im.bootnodes.core :as bootnodes]
[status-im.browser.core :as browser]
[status-im.browser.permissions :as browser.permissions]
Expand Down Expand Up @@ -129,14 +129,7 @@
:multiaccounts.ui/biometric-auth-switched
(fn [cofx [_ biometric-auth?]]
(if biometric-auth?
(biomentric-auth/authenticate-fx
cofx
(fn [{:keys [bioauth-success bioauth-message]}]
(when bioauth-success
(re-frame/dispatch [:multiaccounts.ui/switch-biometric-auth true]))
(when bioauth-message
(utils/show-popup (i18n/label :t/biometric-auth-reason-verify) bioauth-message)))
{:reason (i18n/label :t/biometric-auth-reason-verify)})
(biometric-auth/auth-switched-on-fx cofx)
(multiaccounts/switch-biometric-auth cofx false))))

(handlers/register-handler-fx
Expand Down
4 changes: 3 additions & 1 deletion src/status_im/multiaccounts/create/core.cljs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(ns status-im.multiaccounts.create.core
(:require [clojure.set :refer [map-invert]]
[re-frame.core :as re-frame]
[status-im.biometric-auth.core :as biometric-auth]
[status-im.constants :as constants]
[status-im.ethereum.core :as ethereum]
[status-im.native-module.core :as status]
Expand Down Expand Up @@ -120,7 +121,8 @@
(= step :enable-fingerprint)
(fx/merge cofx
{:db (assoc-in db [:intro-wizard :step] :enable-notifications)}
{:dispatch [:multiaccounts.ui/biometric-auth-switched (not skip?)]})
(when-not skip?
biometric-auth/auth-switched-on-fx))

(= step :generate-key)
(init-key-generation cofx)
Expand Down

0 comments on commit 6e61beb

Please sign in to comment.