Skip to content

Commit

Permalink
ref: addressed @cammellos' review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
clauxx committed Nov 21, 2023
1 parent 742e3d8 commit ec5e459
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
10 changes: 6 additions & 4 deletions src/status_im2/common/keychain/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,18 @@
(str key-uid "-auth")
#(callback (if % (oops/oget % "password") auth-method-none)))
(callback nil))))))

(defn save-user-password!
[key-uid password]
(keychain/save-credentials key-uid key-uid (security/safe-unmask-data password) #()))

(defn get-user-password!
[key-uid callback]
(keychain/get-credentials key-uid
#(if %
(callback (security/mask-data (oops/oget % "password")))
(callback nil))))
#(callback (when %
(-> %
(oops/oget "password")
(security/mask-data))))))

(re-frame/reg-fx
:keychain/get-user-password
Expand Down Expand Up @@ -121,7 +123,7 @@
[key-uid callback]
(keychain/get-credentials
(password-migration-key-name key-uid)
#(callback (boolean %))))
#(comp callback boolean)))

This comment has been minimized.

Copy link
@cammellos

cammellos Nov 21, 2023

Contributor

no need to use an anonymous function here,
just (comp callback boolean) will do


(re-frame/reg-fx
:keychain/clear-user-password
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
[status-im2.contexts.onboarding.enable-biometrics.style :as style]
[status-im2.navigation.state :as state]
[utils.i18n :as i18n]
[utils.re-frame :as rf]
[utils.security.core :as security]))
[utils.re-frame :as rf]))


(defn page-title
Expand Down
4 changes: 2 additions & 2 deletions src/status_im2/contexts/profile/login/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@

(rf/defn get-auth-method-success
{:events [:profile.login/get-auth-method-success]}
[{:keys [db] :as cofx} auth-method key-uid]
[{:keys [db]} auth-method key-uid]
(merge {:db (assoc db :auth-method auth-method)}
(when (= auth-method keychain/auth-method-biometric)
{:keychain/password-hash-migration
Expand Down Expand Up @@ -212,7 +212,7 @@

(rf/defn verify-database-password-success
{:events [:profile.login/verified-database-password]}
[{:keys [db] :as cofx} valid? callback]
[{:keys [db]} valid? callback]
(if valid?
(do
(when (fn? callback)
Expand Down
10 changes: 4 additions & 6 deletions src/utils/security/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@
[text]
(not (re-matches rtlo-link-regex text)))

(defn hash-masked-password
[masked-password]
(-> masked-password
safe-unmask-data
native-module/sha3
mask-data))
(def hash-masked-password
(comp safe-unmask-data
native-module/sha3
mask-data))

0 comments on commit ec5e459

Please sign in to comment.