Skip to content

Commit

Permalink
Do not change keychain method on auth-bio fail
Browse files Browse the repository at this point in the history
Do not change auth method if user does not save password

Sanity check - fix only for biometric method

Check for new auth method only when save password

ScrollView Persist taps on login view

Signed-off-by: Gheorghe Pinzaru <feross95@gmail.com>
  • Loading branch information
Ferossgp committed Feb 25, 2020
1 parent f18e7d7 commit ff1022f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
17 changes: 9 additions & 8 deletions src/status_im/multiaccounts/login/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,12 @@
(multiaccounts/switch-preview-privacy-mode-flag))))

(defn get-new-auth-method [auth-method save-password?]
(if save-password?
(when save-password?
(when-not (or (= keychain/auth-method-biometric auth-method)
(= keychain/auth-method-password auth-method))
(if (= auth-method keychain/auth-method-biometric-prepare)
keychain/auth-method-biometric
keychain/auth-method-password))
(when (and auth-method
(not= auth-method keychain/auth-method-none))
keychain/auth-method-none)))
keychain/auth-method-password))))

(fx/defn login-only-events
[{:keys [db] :as cofx} key-uid password save-password?]
Expand Down Expand Up @@ -393,17 +390,21 @@
(fx/defn biometric-auth-done
{:events [:biometric-auth-done]}
[{:keys [db] :as cofx} {:keys [bioauth-success bioauth-message bioauth-code]}]
(let [key-uid (get-in db [:multiaccounts/login :key-uid])]
(let [key-uid (get-in db [:multiaccounts/login :key-uid])
auth-method (get db :auth-method)]
(log/debug "[biometric] biometric-auth-done"
"bioauth-success" bioauth-success
"bioauth-message" bioauth-message
"bioauth-code" bioauth-code)
(if bioauth-success
(get-credentials cofx key-uid)
(fx/merge cofx
{:db (assoc-in db [:multiaccounts/login :save-password?] false)}
{:db (assoc-in db
[:multiaccounts/login :save-password?]
(= auth-method keychain/auth-method-biometric))}
(when-not (= auth-method keychain/auth-method-biometric)
(keychain/save-auth-method key-uid keychain/auth-method-none))
(biometric/show-message bioauth-message bioauth-code)
(keychain/save-auth-method key-uid keychain/auth-method-none)
(open-login-callback nil)))))

(fx/defn save-password
Expand Down
15 changes: 8 additions & 7 deletions src/status_im/ui/screens/multiaccounts/login/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
supported-biometric-auth [:supported-biometric-auth]]
[react/keyboard-avoiding-view {:style ast/multiaccounts-view}
[login-toolbar can-navigate-back?]
[react/scroll-view styles/login-view
[react/scroll-view {:keyboardShouldPersistTaps :always
:style styles/login-view}
[react/view styles/login-badge-container
[multiaccount-login-badge multiaccount]
[react/view {:style styles/password-container
Expand All @@ -72,7 +73,7 @@
(re-frame/dispatch [:set-in [:multiaccounts/login :password]
(security/mask-data %)])
(re-frame/dispatch [:set-in [:multiaccounts/login :error] ""]))
:secure-text-entry true
:secure-text-entry true
:error (when (not-empty error) error)}]]
(when (and supported-biometric-auth (= auth-method "biometric"))
[react/touchable-highlight {:on-press #(re-frame/dispatch [:biometric-authenticate])}
Expand Down Expand Up @@ -106,9 +107,9 @@
(react/dismiss-keyboard!)
(re-frame/dispatch [:multiaccounts.recover.ui/recover-multiaccount-button-pressed]))}]
[components.common/button
{:label (i18n/label :t/submit)
{:label (i18n/label :t/submit)
:button-style styles/bottom-button
:label-style {:color (if (or (not sign-in-enabled?) processing) colors/gray colors/blue)}
:background? true
:disabled? (or (not sign-in-enabled?) processing)
:on-press #(login-multiaccount @password-text-input)}]]]))
:label-style {:color (if (or (not sign-in-enabled?) processing) colors/gray colors/blue)}
:background? true
:disabled? (or (not sign-in-enabled?) processing)
:on-press #(login-multiaccount @password-text-input)}]]]))

0 comments on commit ff1022f

Please sign in to comment.