diff --git a/.changeset/great-dogs-count.md b/.changeset/great-dogs-count.md new file mode 100644 index 00000000000..145171f6f3a --- /dev/null +++ b/.changeset/great-dogs-count.md @@ -0,0 +1,8 @@ +--- +'@aws-amplify/ui': minor +--- + +feat(ui): allow override of resendSignUpCode function call + +This feature lets you override the `resendSignUpCode` function call the same way as the `signUp`, `signIn`, +`confirmSignIn`, `confirmSignUp`, `forgotPassword` and `forgotPasswordSubmit` functions. diff --git a/docs/src/components/FunctionOverridesTable.tsx b/docs/src/components/FunctionOverridesTable.tsx index 43ccd1ba45e..c048126f38c 100644 --- a/docs/src/components/FunctionOverridesTable.tsx +++ b/docs/src/components/FunctionOverridesTable.tsx @@ -91,6 +91,17 @@ export const FunctionOverridesTable = ({ framework }) => { {'{username, confirmationCode}'} + + + resendSignUpCode + + + handleResendSignUpCode + + + {'{username}'} + + resetPassword @@ -170,6 +181,17 @@ export const FunctionOverridesTable = ({ framework }) => { {'{username, code}'} + + + Auth.resendSignUpCode + + + handleResendSignUpCode + + + {'{username}'} + + Auth.forgotPassword diff --git a/docs/src/pages/[platform]/connected-components/authenticator/customization/customization.override-function-calls.react-native.mdx b/docs/src/pages/[platform]/connected-components/authenticator/customization/customization.override-function-calls.react-native.mdx index 0768d337fd0..46c8c5d6417 100644 --- a/docs/src/pages/[platform]/connected-components/authenticator/customization/customization.override-function-calls.react-native.mdx +++ b/docs/src/pages/[platform]/connected-components/authenticator/customization/customization.override-function-calls.react-native.mdx @@ -6,7 +6,7 @@ import { FunctionOverridesTable } from '@/components/FunctionOverridesTable'; ## Override Function Calls -You can override the call to `signUp`, `signIn`, `confirmSignIn`, `confirmSignUp`, `forgotPassword` and `forgotPasswordSubmit` functions. +You can override the call to `signUp`, `signIn`, `confirmSignIn`, `confirmSignUp`, `resendSignUpCode`, `forgotPassword` and `forgotPasswordSubmit` functions. To override a call you must create a new `services` object with an `async` `handle*` function that returns an `aws-amplify` `Auth` promise. diff --git a/docs/src/pages/[platform]/connected-components/authenticator/customization/customization.override-function-calls.web.mdx b/docs/src/pages/[platform]/connected-components/authenticator/customization/customization.override-function-calls.web.mdx index 3fcba2ffe9c..1fa70b68b4f 100644 --- a/docs/src/pages/[platform]/connected-components/authenticator/customization/customization.override-function-calls.web.mdx +++ b/docs/src/pages/[platform]/connected-components/authenticator/customization/customization.override-function-calls.web.mdx @@ -9,7 +9,7 @@ import { FunctionOverridesTable } from '@/components/FunctionOverridesTable'; ## Override Function Calls -You can override the call to `signUp`, `signIn`, `confirmSignIn`, `confirmSignUp`, `forgotPassword` and `forgotPasswordSubmit` functions. +You can override the call to `signUp`, `signIn`, `confirmSignIn`, `confirmSignUp`, `resendSignUpCode`, `forgotPassword` and `forgotPasswordSubmit` functions. To override a call you must create a new `services` object with an `async` `handle*` function that returns an `aws-amplify` `Auth` promise. The service object must then be passed into the `authenticator` component as a `services` prop. For example, let's imagine you'd like to lowercase the `username` and the `email` attributes during `signUp`. diff --git a/packages/ui/src/machines/authenticator/actors/signIn.ts b/packages/ui/src/machines/authenticator/actors/signIn.ts index 297254dafdc..ca3f2108af9 100644 --- a/packages/ui/src/machines/authenticator/actors/signIn.ts +++ b/packages/ui/src/machines/authenticator/actors/signIn.ts @@ -3,7 +3,6 @@ import { confirmSignIn, ConfirmSignInInput, fetchUserAttributes, - resendSignUpCode, resetPassword, signInWithRedirect, } from 'aws-amplify/auth'; @@ -297,7 +296,7 @@ export function signInActor({ services }: SignInMachineOptions) { return resetPassword({ username }); }, handleResendSignUpCode({ username }) { - return resendSignUpCode({ username }); + return services.handleResendSignUpCode({ username }); }, handleSignIn({ formValues, username }) { const { password } = formValues; diff --git a/packages/ui/src/machines/authenticator/actors/signUp.ts b/packages/ui/src/machines/authenticator/actors/signUp.ts index 7bf68785e64..401b3f0f520 100644 --- a/packages/ui/src/machines/authenticator/actors/signUp.ts +++ b/packages/ui/src/machines/authenticator/actors/signUp.ts @@ -3,7 +3,6 @@ import { createMachine, sendUpdate } from 'xstate'; import { autoSignIn, ConfirmSignUpInput, - resendSignUpCode, signInWithRedirect, fetchUserAttributes, } from 'aws-amplify/auth'; @@ -287,7 +286,7 @@ export function signUpActor({ services }: SignUpMachineOptions) { return services.handleConfirmSignUp(input); }, resendSignUpCode({ username }) { - return resendSignUpCode({ username }); + return services.handleResendSignUpCode({ username }); }, signInWithRedirect(_, { data }) { return signInWithRedirect(data); diff --git a/packages/ui/src/machines/authenticator/defaultServices.ts b/packages/ui/src/machines/authenticator/defaultServices.ts index c7a3cb02940..790178bb79c 100644 --- a/packages/ui/src/machines/authenticator/defaultServices.ts +++ b/packages/ui/src/machines/authenticator/defaultServices.ts @@ -6,6 +6,7 @@ import { confirmSignIn, confirmSignUp, getCurrentUser, + resendSignUpCode, resetPassword, signIn, signUp, @@ -89,6 +90,7 @@ export const defaultServices = { handleConfirmSignUp: confirmSignUp, handleForgotPasswordSubmit: confirmResetPassword, handleForgotPassword: resetPassword, + handleResendSignUpCode: resendSignUpCode, // Validation hooks for overriding async validateCustomSignUp(