-
Notifications
You must be signed in to change notification settings - Fork 984
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
269 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
(ns quo.components.separator | ||
(:require [quo.react-native :as react] | ||
[quo.design-system.colors :as colors])) | ||
|
||
(defn separator [{:keys [color style]}] | ||
[react/view | ||
{:style | ||
(merge | ||
style | ||
{:background-color (colors/get-color (or color :ui-01)) | ||
:align-self :stretch | ||
:height 1})}]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
src/status_im/ui/screens/privacy_and_security_settings/delete_profile.cljs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
(ns status-im.ui.screens.privacy-and-security-settings.delete-profile | ||
(:require [status-im.ui.components.react :as react] | ||
[quo.core :as quo] | ||
[status-im.multiaccounts.core :as multiaccounts] | ||
[status-im.ui.components.chat-icon.screen :as chat-icon.screen] | ||
[re-frame.core :as re-frame] | ||
[status-im.ui.components.topbar :as topbar] | ||
[status-im.ui.components.styles :as components.styles] | ||
[status-im.i18n :as i18n] | ||
[reagent.core :as reagent] | ||
[status-im.utils.security :as security] | ||
[status-im.ui.screens.privacy-and-security-settings.events :as delete-profile])) | ||
|
||
(defn valid-password? [password] | ||
(>= (count password) 6)) | ||
|
||
(defn keycard-pin [] | ||
#_(let [pin @(re-frame/subscribe [:keycard/pin]) | ||
step @(re-frame/subscribe [:keycard/pin-enter-step]) | ||
status @(re-frame/subscribe [:keycard/pin-status]) | ||
pin-retry-counter @(re-frame/subscribe [:keycard/pin-retry-counter]) | ||
puk-retry-counter @(re-frame/subscribe [:keycard/puk-retry-counter]) | ||
error-label @(re-frame/subscribe [:keycard/pin-error-label])] | ||
[pin.views/pin-view | ||
{:pin pin | ||
:status status | ||
:retry-counter pin-retry-counter | ||
:error-label error-label | ||
:step :current}])) | ||
|
||
(defn delete-profile [] | ||
(let [password (reagent/atom nil) | ||
text-input-ref (atom nil)] | ||
(fn [] | ||
(let [keycard? @(re-frame/subscribe [:keycard-multiaccount?]) | ||
multiaccount @(re-frame/subscribe [:multiaccount]) | ||
error @(re-frame/subscribe [:delete-profile/error])] | ||
(when (and @text-input-ref error (not @password)) | ||
(.clear ^js @text-input-ref)) | ||
[react/view components.styles/flex | ||
[topbar/topbar {:modal? true}] | ||
[react/view | ||
{:style {:flex 1 | ||
:justify-content :space-between}} | ||
[react/scroll-view {:style {:flex 1}} | ||
[react/view {:style {:align-items :center}} | ||
[quo/text {:weight :bold | ||
:size :x-large} | ||
(i18n/label :t/delete-profile)]] | ||
[quo/list-item | ||
{:title (multiaccounts/displayed-name multiaccount) | ||
:icon [chat-icon.screen/contact-icon-contacts-tab | ||
(multiaccounts/displayed-photo multiaccount)]}] | ||
[quo/text {:style {:margin-horizontal 24} | ||
:align :center | ||
:color :negative} | ||
(i18n/label :t/delete-profile-warning)] | ||
(if keycard? | ||
[keycard-pin] | ||
[quo/text-input | ||
{:style {:margin-horizontal 36 | ||
:margin-top 36} | ||
:show-cancel false | ||
:secure-text-entry true | ||
:return-key-type :next | ||
:on-submit-editing nil | ||
:auto-focus true | ||
:on-change-text #(reset! password (security/mask-data %)) | ||
:bottom-value 36 | ||
:get-ref #(reset! text-input-ref %) | ||
:error (when (and error (not @password)) | ||
(if (= :wrong-password error) | ||
(i18n/label :t/wrong-password) | ||
(str error)))}])] | ||
(when-not keycard? | ||
[react/view {:style {:align-items :center}} | ||
[quo/separator] | ||
[react/view | ||
{:style {:margin-vertical 8}} | ||
[quo/button {:on-press #(do | ||
(re-frame/dispatch | ||
[::delete-profile/delete-profile @password]) | ||
(reset! password nil)) | ||
:theme :negative | ||
:disabled ((complement valid-password?) @password)} | ||
(i18n/label :t/delete-profile)]]])]])))) |
67 changes: 67 additions & 0 deletions
67
src/status_im/ui/screens/privacy_and_security_settings/events.cljs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
(ns status-im.ui.screens.privacy-and-security-settings.events | ||
(:require [status-im.utils.fx :as fx] | ||
[re-frame.core :as re-frame] | ||
[status-im.utils.security :as security] | ||
[status-im.native-module.core :as status] | ||
[status-im.ethereum.core :as ethereum] | ||
[status-im.utils.types :as types] | ||
[taoensso.timbre :as log] | ||
[clojure.string :as clojure.string] | ||
[status-im.i18n :as i18n])) | ||
|
||
(defn safe-blank? [s] | ||
(or (not s) | ||
(clojure.string/blank? s))) | ||
|
||
(re-frame/reg-fx | ||
::delete-profile | ||
(fn [{:keys [address key-uid callback masked-password]}] | ||
(let [hashed-password | ||
(-> masked-password | ||
security/safe-unmask-data | ||
ethereum/sha3)] | ||
(status/verify | ||
address | ||
hashed-password | ||
(fn [result] | ||
(let [{:keys [error]} (types/json->clj result)] | ||
(log/info "[delete-profile] verify-password" result error) | ||
(if-not (safe-blank? error) | ||
(callback :wrong-password nil) | ||
(status/delete-multiaccount | ||
key-uid | ||
(fn [result] | ||
(let [{:keys [error]} (types/json->clj result)] | ||
(callback error nil))))))))))) | ||
|
||
(fx/defn delete-profile | ||
{:events [::delete-profile]} | ||
[{:keys [db] :as cofx} masked-password] | ||
(log/info "[delete-profile] delete") | ||
(let [{:keys [key-uid wallet-root-address]} (:multiaccount db)] | ||
{:db (dissoc db :delete-profile/error) | ||
::delete-profile | ||
{:masked-password masked-password | ||
:key-uid key-uid | ||
:address wallet-root-address | ||
:callback | ||
(fn [error result] | ||
(log/info "[delete-profile] callback" error) | ||
(if (safe-blank? error) | ||
(re-frame/dispatch [::on-delete-profile-success result]) | ||
(re-frame/dispatch [::on-delete-profile-failure error])))}})) | ||
|
||
(fx/defn on-delete-profile-success | ||
{:events [::on-delete-profile-success]} | ||
[cofx] | ||
(log/info "[delete-profile] on-success") | ||
{:utils/show-popup | ||
{:title (i18n/label :t/profile-deleted-title) | ||
:content (i18n/label :t/profile-deleted-content) | ||
:on-dismiss #(re-frame/dispatch [:logout])}}) | ||
|
||
(fx/defn on-delete-profile-failure | ||
{:events [::on-delete-profile-failure]} | ||
[{:keys [db]} error] | ||
(log/info "[delete-profile] on-failure" error) | ||
{:db (assoc db :delete-profile/error error)}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.