fix: App gets stuck on syncing process screen when scanning QR code v… (#18140)

* fix: App gets stuck on syncing process screen when scanning QR code via recovered profile with different passwords

* update comment
This commit is contained in:
frank 2023-12-16 10:25:39 +08:00 committed by GitHub
parent f8e935c58d
commit e06d8cb106
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 38 additions and 24 deletions

View File

@ -95,8 +95,9 @@
accounts-data)))
(rf/defn save-account-and-login
[_ key-uid multiaccount-data password settings node-config accounts-data]
{::save-account-and-login [key-uid
[{:keys [db]} key-uid multiaccount-data password settings node-config accounts-data]
{:db (assoc-in db [:syncing :login-sha3-password] password)
::save-account-and-login [key-uid
(types/clj->json multiaccount-data)
password
(types/clj->json settings)

View File

@ -22,7 +22,8 @@
:network/type type
:initials-avatar-font-file initials-avatar-font-file
:keycard (dissoc keycard :secrets :pin :application-info)
:biometric/supported-type supported-type)})
:biometric/supported-type supported-type
:syncing nil)})
(rf/defn logout-method
{:events [::logout-method]}

View File

@ -9,11 +9,13 @@
(rf/defn create-profile-and-login
{:events [:profile.create/create-and-login]}
[_ {:keys [display-name password image-path color]}]
{:effects.profile/create-and-login
[{:keys [db]} {:keys [display-name password image-path color]}]
(let [login-sha3-password (native-module/sha3 (security/safe-unmask-data password))]
{:db (assoc-in db [:syncing :login-sha3-password] login-sha3-password)
:effects.profile/create-and-login
(assoc (profile.config/create)
:displayName display-name
:password (native-module/sha3 (security/safe-unmask-data password))
:password login-sha3-password
:imagePath (profile.config/strip-file-prefix image-path)
:customizationColor color
:emoji (emoji-picker.utils/random-emoji))})
:emoji (emoji-picker.utils/random-emoji))}))

View File

@ -33,9 +33,12 @@
(rf/defn login
{:events [:profile.login/login]}
[{:keys [db]}]
(let [{:keys [key-uid password]} (:profile/login db)]
{:db (assoc-in db [:profile/login :processing] true)
:effects.profile/login [key-uid (native-module/sha3 (security/safe-unmask-data password))]}))
(let [{:keys [key-uid password]} (:profile/login db)
login-sha3-password (native-module/sha3 (security/safe-unmask-data password))]
{:db (-> db
(assoc-in [:profile/login :processing] true)
(assoc-in [:syncing :login-sha3-password] login-sha3-password))
:effects.profile/login [key-uid login-sha3-password]}))
(rf/defn biometrics-login
{:events [:profile.login/biometrics-login]}
@ -48,6 +51,10 @@
{:events [:profile.login/local-paired-user]}
[{:keys [db]}]
(let [{:keys [key-uid password]} (get-in db [:syncing :profile])
login-sha3-password (get-in db [:syncing :login-sha3-password])
password (if-not (nil? login-sha3-password) ;; already logged in
login-sha3-password
password)
masked-password (security/mask-data password)]
{:db (-> db
(assoc-in [:onboarding/profile :password] masked-password)

View File

@ -10,14 +10,17 @@
(rf/defn recover-profile-and-login
{:events [:profile.recover/recover-and-login]}
[{:keys [db]} {:keys [display-name password image-path color seed-phrase]}]
(let [login-sha3-password (native-module/sha3 (security/safe-unmask-data password))]
{:db
(assoc db :onboarding/recovered-account? true)
(-> db
(assoc :onboarding/recovered-account? true)
(assoc-in [:syncing :login-sha3-password] login-sha3-password))
:effects.profile/restore-and-login
(merge (profile.config/create)
{:displayName display-name
:mnemonic (security/safe-unmask-data seed-phrase)
:password (native-module/sha3 (security/safe-unmask-data password))
:password login-sha3-password
:imagePath (profile.config/strip-file-prefix image-path)
:customizationColor color
:emoji (emoji-picker.utils/random-emoji)})})
:emoji (emoji-picker.utils/random-emoji)})}))