@@ -68,7 +68,12 @@ export const ProfileAuthCard = () => {
6868 } ) ;
6969
7070 const { mutate : disableMfaMutation } = useMutation ( {
71- mutationFn : api . auth . mfa . disable ,
71+ mutationFn : ( ) => {
72+ if ( user . username === authUsername ) {
73+ return api . auth . mfa . disable ( ) ;
74+ }
75+ return api . user . disableMfa ( user . username ) ;
76+ } ,
7277 meta : invalidateAfterMfaChange ,
7378 } ) ;
7479
@@ -101,7 +106,7 @@ export const ProfileAuthCard = () => {
101106 } ) ;
102107 const emailMenuItems = useMemo ( ( ) => {
103108 const items : MenuItemProps [ ] = [ ] ;
104- if ( ! user . email_mfa_enabled ) {
109+ if ( ! user . email_mfa_enabled && user . username === authUsername ) {
105110 items . push ( {
106111 testId : 'enable-email' ,
107112 text : m . controls_enable ( ) ,
@@ -126,13 +131,14 @@ export const ProfileAuthCard = () => {
126131 const res : MenuItemsGroup = {
127132 items,
128133 } ;
129- return res ;
134+ return items . length > 0 ? res : null ;
130135 } , [
131136 user . email_mfa_enabled ,
132137 mutateDisableEmailMfa ,
133138 mutateSetDefaultMfa ,
134139 user . mfa_method ,
135140 user . username ,
141+ authUsername ,
136142 ] ) ;
137143
138144 const mfaMenuItems = useMemo ( ( ) => {
@@ -178,12 +184,14 @@ export const ProfileAuthCard = () => {
178184
179185 const webauthnMenuItems = useMemo ( ( ) => {
180186 const items : MenuItemProps [ ] = [ ] ;
181- items . push ( {
182- text : m . profile_auth_card_add_passkey ( ) ,
183- icon : 'plus-circle' ,
184- testId : 'add-passkey' ,
185- onClick : ( ) => openModal ( ModalName . WebauthnSetup ) ,
186- } ) ;
187+ if ( user . username === authUsername ) {
188+ items . push ( {
189+ text : m . profile_auth_card_add_passkey ( ) ,
190+ icon : 'plus-circle' ,
191+ testId : 'add-passkey' ,
192+ onClick : ( ) => openModal ( ModalName . WebauthnSetup ) ,
193+ } ) ;
194+ }
187195 if ( securityKeys . length ) {
188196 if ( user . mfa_method !== UserMfaMethod . Webauthn ) {
189197 items . push ( {
@@ -199,14 +207,19 @@ export const ProfileAuthCard = () => {
199207 onClick : ( ) => mutateDisableWebauthn ( ) ,
200208 } ) ;
201209 }
202- return {
203- items,
204- } ;
205- } , [ mutateDisableWebauthn , securityKeys . length , mutateSetDefaultMfa , user . mfa_method ] ) ;
210+ return items . length > 0 ? { items } : null ;
211+ } , [
212+ mutateDisableWebauthn ,
213+ securityKeys . length ,
214+ mutateSetDefaultMfa ,
215+ user . mfa_method ,
216+ user . username ,
217+ authUsername ,
218+ ] ) ;
206219
207220 const totpMenuItems = useMemo ( ( ) => {
208221 const items : MenuItemProps [ ] = [ ] ;
209- if ( ! user . totp_enabled ) {
222+ if ( ! user . totp_enabled && user . username === authUsername ) {
210223 items . push ( {
211224 icon : 'check-circle' ,
212225 testId : 'enable-totp' ,
@@ -231,15 +244,14 @@ export const ProfileAuthCard = () => {
231244 } ) ;
232245 }
233246
234- return {
235- items,
236- } ;
247+ return items . length > 0 ? { items } : null ;
237248 } , [
238249 mutateDisableTotp ,
239250 user . totp_enabled ,
240251 mutateSetDefaultMfa ,
241252 user . mfa_method ,
242253 user . username ,
254+ authUsername ,
243255 ] ) ;
244256
245257 return (
@@ -393,7 +405,7 @@ interface FactorRowProps {
393405 enabled : boolean ;
394406 isDefault : boolean ;
395407 availability : 'sso' | 'both' | 'mfa' ;
396- menu ?: MenuItemsGroup ;
408+ menu ?: MenuItemsGroup | null ;
397409 testId ?: string ;
398410}
399411
0 commit comments