Skip to content

Commit

Permalink
fix: App gets stuck on syncing process screen when scanning QR code v… (
Browse files Browse the repository at this point in the history
#18140)

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

* update comment
  • Loading branch information
qfrank authored Dec 16, 2023
1 parent f8e935c commit e06d8cb
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 24 deletions.
5 changes: 3 additions & 2 deletions src/status_im/multiaccounts/create/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion src/status_im/multiaccounts/logout/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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]}
Expand Down
18 changes: 10 additions & 8 deletions src/status_im2/contexts/profile/create/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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
(assoc (profile.config/create)
:displayName display-name
:password (native-module/sha3 (security/safe-unmask-data password))
:imagePath (profile.config/strip-file-prefix image-path)
:customizationColor color
:emoji (emoji-picker.utils/random-emoji))})
[{: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 login-sha3-password
:imagePath (profile.config/strip-file-prefix image-path)
:customizationColor color
:emoji (emoji-picker.utils/random-emoji))}))
13 changes: 10 additions & 3 deletions src/status_im2/contexts/profile/login/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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]}
Expand All @@ -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)
Expand Down
23 changes: 13 additions & 10 deletions src/status_im2/contexts/profile/recover/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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]}]
{:db
(assoc db :onboarding/recovered-account? true)
(let [login-sha3-password (native-module/sha3 (security/safe-unmask-data password))]
{:db
(-> 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))
:imagePath (profile.config/strip-file-prefix image-path)
:customizationColor color
:emoji (emoji-picker.utils/random-emoji)})})
:effects.profile/restore-and-login
(merge (profile.config/create)
{:displayName display-name
:mnemonic (security/safe-unmask-data seed-phrase)
:password login-sha3-password
:imagePath (profile.config/strip-file-prefix image-path)
:customizationColor color
:emoji (emoji-picker.utils/random-emoji)})}))

0 comments on commit e06d8cb

Please sign in to comment.