Add biometric auth if available to communities password input (#19336)

This commit is contained in:
Ibrahem Khalil 2024-04-03 11:18:15 +02:00 committed by GitHub
parent 68402ae669
commit 7e896979f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 54 additions and 49 deletions

View File

@ -3,7 +3,8 @@
[promesa.core :as promesa] [promesa.core :as promesa]
[schema.core :as schema] [schema.core :as schema]
[status-im.common.json-rpc.events :as rpc] [status-im.common.json-rpc.events :as rpc]
[utils.re-frame :as rf])) [utils.re-frame :as rf]
[utils.security.core :as security]))
(defn- generate-requests-for-signing (defn- generate-requests-for-signing
[pub-key community-id addresses-to-reveal] [pub-key community-id addresses-to-reveal]
@ -21,7 +22,7 @@
(fn [p-resolve p-reject] (fn [p-resolve p-reject]
(rpc/call (rpc/call
{:method :wakuext_signData {:method :wakuext_signData
:params [(map #(assoc % :password password) sign-params)] :params [(map #(assoc % :password (security/safe-unmask-data password)) sign-params)]
:on-success p-resolve :on-success p-resolve
:on-error #(p-reject (str "failed to sign data\n" %))})))) :on-error #(p-reject (str "failed to sign data\n" %))}))))
@ -80,7 +81,7 @@
[:cat [:cat
[:map {:closed true} [:map {:closed true}
[:community-id string?] [:community-id string?]
[:password string?] [:password [:maybe [:or string? object?]]]
[:pub-key string?] [:pub-key string?]
[:addresses-to-reveal [:addresses-to-reveal
[:or [:set string?] [:or [:set string?]

View File

@ -3,7 +3,6 @@
[quo.core :as quo] [quo.core :as quo]
[react-native.core :as rn] [react-native.core :as rn]
[react-native.gesture :as gesture] [react-native.gesture :as gesture]
[status-im.common.password-authentication.view :as password-authentication]
[status-im.contexts.communities.actions.accounts-selection.style :as style] [status-im.contexts.communities.actions.accounts-selection.style :as style]
[status-im.contexts.communities.actions.addresses-for-permissions.view :as addresses-for-permissions] [status-im.contexts.communities.actions.addresses-for-permissions.view :as addresses-for-permissions]
[status-im.contexts.communities.actions.airdrop-addresses.view :as airdrop-addresses] [status-im.contexts.communities.actions.airdrop-addresses.view :as airdrop-addresses]
@ -58,12 +57,15 @@
(rn/use-callback (rn/use-callback
(fn [] (fn []
(rf/dispatch (rf/dispatch
[:password-authentication/show [:standard-auth/authorize
{:content (fn [] [password-authentication/view])} {:auth-button-label (if can-edit-addresses?
{:label (i18n/label :t/join-open-community) (i18n/label :t/edit-shared-addresses)
:on-press (fn [password] (i18n/label :t/request-to-join))
(rf/dispatch [:communities/request-to-join-with-addresses :on-auth-success (fn [password]
{:community-id id :password password}]))}]) (rf/dispatch
[:communities/request-to-join-with-addresses
{:community-id id
:password password}]))}])
(navigate-back))) (navigate-back)))
open-permission-sheet open-permission-sheet

View File

@ -4,7 +4,6 @@
[quo.core :as quo] [quo.core :as quo]
[react-native.core :as rn] [react-native.core :as rn]
[react-native.gesture :as gesture] [react-native.gesture :as gesture]
[status-im.common.password-authentication.view :as password-authentication]
[status-im.constants :as constants] [status-im.constants :as constants]
[status-im.contexts.communities.actions.addresses-for-permissions.style :as style] [status-im.contexts.communities.actions.addresses-for-permissions.style :as style]
[status-im.contexts.communities.actions.permissions-sheet.view :as permissions-sheet] [status-im.contexts.communities.actions.permissions-sheet.view :as permissions-sheet]
@ -222,22 +221,22 @@
confirm-changes confirm-changes
(fn [] (fn []
(if can-edit-addresses? (if can-edit-addresses?
(rf/dispatch
[:password-authentication/show
{:content (fn [] [password-authentication/view])}
{:label (i18n/label :t/enter-password)
:on-press (fn [password]
(rf/dispatch
[:communities/edit-shared-addresses
{:community-id id
:password password
:addresses addresses-to-reveal
:on-success (fn []
(rf/dispatch [:dismiss-modal :addresses-for-permissions])
(rf/dispatch [:hide-bottom-sheet]))}]))}])
(do (do
(rf/dispatch [:communities/set-share-all-addresses id flag-share-all-addresses]) (rf/dispatch
(rf/dispatch [:communities/set-addresses-to-reveal id addresses-to-reveal])))) [:standard-auth/authorize
{:auth-button-label (i18n/label :t/confirm-changes)
:on-auth-success (fn [password]
(rf/dispatch
[:communities/edit-shared-addresses
{:community-id id
:password password
:addresses addresses-to-reveal
:on-success (fn []
(rf/dispatch [:dismiss-modal
:addresses-for-permissions])
(rf/dispatch [:hide-bottom-sheet]))}]))}])
(rf/dispatch [:communities/set-share-all-addresses id flag-share-all-addresses]))
(rf/dispatch [:communities/set-addresses-to-reveal id addresses-to-reveal])))
pending? (rf/sub [:communities/has-pending-request-to-join? id]) pending? (rf/sub [:communities/has-pending-request-to-join? id])
highest-role (rf/sub [:communities/highest-role-for-selection id]) highest-role (rf/sub [:communities/highest-role-for-selection id])
[unmodified-role _] (rn/use-state highest-role)] [unmodified-role _] (rn/use-state highest-role)]

View File

@ -4,7 +4,6 @@
[react-native.core :as rn] [react-native.core :as rn]
[react-native.gesture :as gesture] [react-native.gesture :as gesture]
[status-im.common.not-implemented :as not-implemented] [status-im.common.not-implemented :as not-implemented]
[status-im.common.password-authentication.view :as password-authentication]
[status-im.contexts.communities.actions.airdrop-addresses.style :as style] [status-im.contexts.communities.actions.airdrop-addresses.style :as style]
[utils.i18n :as i18n] [utils.i18n :as i18n]
[utils.re-frame :as rf])) [utils.re-frame :as rf]))
@ -19,18 +18,20 @@
(fn [] (fn []
(if can-edit-addresses? (if can-edit-addresses?
(rf/dispatch (rf/dispatch
[:password-authentication/show [:standard-auth/authorize
{:content (fn [] [password-authentication/view])} {:auth-button-label (i18n/label :t/confirm-changes)
{:label (i18n/label :t/enter-password) :on-auth-success (fn [password]
:on-press (fn [password] (rf/dispatch
(rf/dispatch [:communities/edit-shared-addresses
[:communities/edit-shared-addresses {:community-id community-id
{:community-id community-id :password password
:password password :airdrop-address address
:airdrop-address address :on-success (fn []
:on-success (fn [] (rf/dispatch
(rf/dispatch [:dismiss-modal :address-for-airdrop]) [:dismiss-modal
(rf/dispatch [:hide-bottom-sheet]))}]))}]) :address-for-airdrop])
(rf/dispatch
[:hide-bottom-sheet]))}]))}])
(do (do
(rf/dispatch [:communities/set-airdrop-address community-id address]) (rf/dispatch [:communities/set-airdrop-address community-id address])
(rf/dispatch [:hide-bottom-sheet])))))] (rf/dispatch [:hide-bottom-sheet])))))]

View File

@ -5,7 +5,6 @@
[quo.theme] [quo.theme]
[react-native.core :as rn] [react-native.core :as rn]
[react-native.gesture :as gesture] [react-native.gesture :as gesture]
[status-im.common.password-authentication.view :as password-authentication]
[status-im.contexts.communities.actions.community-rules-list.view :as community-rules] [status-im.contexts.communities.actions.community-rules-list.view :as community-rules]
[status-im.contexts.communities.actions.request-to-join.style :as style] [status-im.contexts.communities.actions.request-to-join.style :as style]
[utils.i18n :as i18n] [utils.i18n :as i18n]
@ -13,11 +12,14 @@
(defn join-community-and-navigate-back (defn join-community-and-navigate-back
[id] [id]
(rf/dispatch [:password-authentication/show (rf/dispatch
{:content (fn [] [password-authentication/view])} [:standard-auth/authorize
{:label (i18n/label :t/join-open-community) {:auth-button-label (i18n/label :t/request-to-join)
:on-press #(rf/dispatch [:communities/request-to-join :on-auth-success (fn [password]
{:community-id id :password %}])}]) (rf/dispatch
[:communities/request-to-join
{:community-id id :password password}]))}])
(rf/dispatch [:navigate-back])) (rf/dispatch [:navigate-back]))
(defn- view-internal (defn- view-internal

View File

@ -3,7 +3,8 @@
[status-im.contexts.communities.utils :as utils] [status-im.contexts.communities.utils :as utils]
[taoensso.timbre :as log] [taoensso.timbre :as log]
[utils.i18n :as i18n] [utils.i18n :as i18n]
[utils.re-frame :as rf])) [utils.re-frame :as rf]
[utils.security.core :as security]))
(rf/reg-event-fx :communities/check-permissions-to-join-community-success (rf/reg-event-fx :communities/check-permissions-to-join-community-success
(fn [{:keys [db]} [community-id based-on-client-selection? result]] (fn [{:keys [db]} [community-id based-on-client-selection? result]]
@ -89,7 +90,7 @@
(let [addresses-to-reveal (map :account sign-params)] (let [addresses-to-reveal (map :account sign-params)]
{:fx [[:json-rpc/call {:fx [[:json-rpc/call
[{:method "wakuext_signData" [{:method "wakuext_signData"
:params [(map #(assoc % :password password) sign-params)] :params [(map #(assoc % :password (security/safe-unmask-data password)) sign-params)]
:on-success [:communities/request-to-join-with-signatures community-id addresses-to-reveal] :on-success [:communities/request-to-join-with-signatures community-id addresses-to-reveal]
:on-error [:communities/requested-to-join-error community-id]}]]]})) :on-error [:communities/requested-to-join-error community-id]}]]]}))

View File

@ -420,8 +420,7 @@ class CommunityView(HomeView):
self.join_button.wait_and_click(120) self.join_button.wait_and_click(120)
self.slide_to_request_to_join_button.swipe_right_on_element(width_percentage=16) self.slide_to_request_to_join_button.swipe_right_on_element(width_percentage=16)
self.password_input.send_keys(password) self.password_input.send_keys(password)
Button(self.driver, self.login_button.click()
xpath="//*[@content-desc='password-input']/../following-sibling::*//*[@text='Join Community']").click()
if open_community: if open_community:
self.community_status_joined.wait_for_visibility_of_element(60) self.community_status_joined.wait_for_visibility_of_element(60)