Skip to content

Commit 875d39b

Browse files
committed
feat: integrate MFA handling in UserEditDialogComponent for user updates
1 parent ff7ea6a commit 875d39b

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

src/packages/ce/src/user/components/UserEditDialogComponent.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import {
3636
IconShieldLock
3737
} from "@tabler/icons-react";
3838
import {UserSessionsDataTableComponent} from "@edition/user/components/UserSessionsDataTableComponent";
39+
import {useMfa} from "@edition/user/components/MfaProviderComponent";
3940
import {UserMfaView} from "@edition/user/views/UserMfaView";
4041
import {SettingDialog} from "@core/components/SettingDialog";
4142

@@ -51,6 +52,7 @@ export const UserEditDialogComponent: React.FC<UserEditDialogComponentProps> = (
5152

5253
const userService = useService(UserService)
5354
const userStore = useStore(UserService)
55+
const withMfa = useMfa()
5456
const [, startTransition] = React.useTransition()
5557

5658
const currentSession = useUserSession()
@@ -132,11 +134,12 @@ export const UserEditDialogComponent: React.FC<UserEditDialogComponentProps> = (
132134
}
133135

134136
startTransition(async () => {
135-
await userService.usersUpdate(payload).then(payload => {
136-
if (payload?.user && (payload?.errors?.length ?? 0) <= 0) {
137-
toast({title: "Updated user", color: "success"})
138-
}
139-
})
137+
// usersUpdate may require a fresh MFA confirmation. withMfa shows the step-up
138+
// dialog and retries with the mfa merged into the payload.
139+
const result = await withMfa((mfa) => userService.usersUpdate({...payload, ...(mfa ? {mfa} : {})}))
140+
if (result?.user && (result?.errors?.length ?? 0) <= 0) {
141+
toast({title: "Updated user", color: "success"})
142+
}
140143
})
141144
}
142145
})

0 commit comments

Comments
 (0)