Skip to content

Commit

Permalink
add onSuccess to MfaListWidget
Browse files Browse the repository at this point in the history
  • Loading branch information
moust committed Jan 31, 2025
1 parent 904502f commit 13e1f0c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/widgets/mfa/MfaCredentialsWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ const MainView = ({
</div>
}

{config.mfaEmailEnabled && config.mfaSmsEnabled && !isPhoneCredentialRegistered && <Separator text={i18n('or')} />}
{config.mfaEmailEnabled && !isEmailCredentialRegistered && config.mfaSmsEnabled && !isPhoneCredentialRegistered && <Separator text={i18n('or')} />}

{config.mfaSmsEnabled && !isPhoneCredentialRegistered &&
<div>
Expand Down
15 changes: 11 additions & 4 deletions src/widgets/mfa/mfaListWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ export type MfaListWidgetProps = {
* The authorization credential JSON Web Token (JWT) used to access the ReachFive API, less than five minutes old.
*/
accessToken: string
/**
* Callback function called when the request has succeed.
*/
onSuccess?: () => void
/**
* Callback function called when the request has failed.
*/
Expand All @@ -94,10 +98,13 @@ export default createWidget<MfaListWidgetProps, MfaListProps>({
component: MfaList,
prepare: (options, { apiClient }) =>
apiClient.listMfaCredentials(options.accessToken)
.then(({ credentials }) => ({
...options,
credentials,
}))
.then(({ credentials }) => {
options.onSuccess?.()
return {
...options,
credentials,
}
})
.catch(error => {
options.onError?.(error)
throw UserError.fromAppError(error)
Expand Down
6 changes: 5 additions & 1 deletion types/identity-ui.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @reachfive/identity-ui - v1.31.3
* Compiled Fri, 31 Jan 2025 13:36:32 UTC
* Compiled Fri, 31 Jan 2025 14:43:05 UTC
*
* Copyright (c) ReachFive.
*
Expand Down Expand Up @@ -1487,6 +1487,10 @@ type MfaListWidgetProps = {
* The authorization credential JSON Web Token (JWT) used to access the ReachFive API, less than five minutes old.
*/
accessToken: string;
/**
* Callback function called when the request has succeed.
*/
onSuccess?: () => void;
/**
* Callback function called when the request has failed.
*/
Expand Down

0 comments on commit 13e1f0c

Please sign in to comment.