Skip to content

Commit 81543cb

Browse files
feat(ui): allow override of resendSignUpCode function call (#6312)
Co-authored-by: Caleb Pollman <[email protected]>
1 parent e6248bd commit 81543cb

File tree

7 files changed

+36
-6
lines changed

7 files changed

+36
-6
lines changed

.changeset/great-dogs-count.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@aws-amplify/ui': minor
3+
---
4+
5+
feat(ui): allow override of resendSignUpCode function call
6+
7+
This feature lets you override the `resendSignUpCode` function call the same way as the `signUp`, `signIn`,
8+
`confirmSignIn`, `confirmSignUp`, `forgotPassword` and `forgotPasswordSubmit` functions.

docs/src/components/FunctionOverridesTable.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,17 @@ export const FunctionOverridesTable = ({ framework }) => {
9191
<code>{'{username, confirmationCode}'}</code>
9292
</ResponsiveTableCell>
9393
</TableRow>
94+
<TableRow>
95+
<ResponsiveTableCell label="Function Call">
96+
<code>resendSignUpCode</code>
97+
</ResponsiveTableCell>
98+
<ResponsiveTableCell label="Override Name">
99+
<code>handleResendSignUpCode</code>
100+
</ResponsiveTableCell>
101+
<ResponsiveTableCell label="input Properties">
102+
<code>{'{username}'}</code>
103+
</ResponsiveTableCell>
104+
</TableRow>
94105
<TableRow>
95106
<ResponsiveTableCell label="Function Call">
96107
<code>resetPassword</code>
@@ -170,6 +181,17 @@ export const FunctionOverridesTable = ({ framework }) => {
170181
<code>{'{username, code}'}</code>
171182
</ResponsiveTableCell>
172183
</TableRow>
184+
<TableRow>
185+
<ResponsiveTableCell label="Function Call">
186+
<code>Auth.resendSignUpCode</code>
187+
</ResponsiveTableCell>
188+
<ResponsiveTableCell label="Override Name">
189+
<code>handleResendSignUpCode</code>
190+
</ResponsiveTableCell>
191+
<ResponsiveTableCell label="formData Properties">
192+
<code>{'{username}'}</code>
193+
</ResponsiveTableCell>
194+
</TableRow>
173195
<TableRow>
174196
<ResponsiveTableCell label="Function Call">
175197
<code>Auth.forgotPassword</code>

docs/src/pages/[platform]/connected-components/authenticator/customization/customization.override-function-calls.react-native.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { FunctionOverridesTable } from '@/components/FunctionOverridesTable';
66

77
## Override Function Calls
88

9-
You can override the call to `signUp`, `signIn`, `confirmSignIn`, `confirmSignUp`, `forgotPassword` and `forgotPasswordSubmit` functions.
9+
You can override the call to `signUp`, `signIn`, `confirmSignIn`, `confirmSignUp`, `resendSignUpCode`, `forgotPassword` and `forgotPasswordSubmit` functions.
1010
To override a call you must create a new `services` object with an `async` `handle*` function that returns an `aws-amplify` `Auth` promise.
1111
<ForgotPasswordCallout />
1212

docs/src/pages/[platform]/connected-components/authenticator/customization/customization.override-function-calls.web.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { FunctionOverridesTable } from '@/components/FunctionOverridesTable';
99

1010
## Override Function Calls
1111

12-
You can override the call to `signUp`, `signIn`, `confirmSignIn`, `confirmSignUp`, `forgotPassword` and `forgotPasswordSubmit` functions.
12+
You can override the call to `signUp`, `signIn`, `confirmSignIn`, `confirmSignUp`, `resendSignUpCode`, `forgotPassword` and `forgotPasswordSubmit` functions.
1313
To override a call you must create a new `services` object with an `async` `handle*` function that returns an `aws-amplify` `Auth` promise.
1414
<ForgotPasswordCallout />
1515
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`.

packages/ui/src/machines/authenticator/actors/signIn.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
confirmSignIn,
44
ConfirmSignInInput,
55
fetchUserAttributes,
6-
resendSignUpCode,
76
resetPassword,
87
signInWithRedirect,
98
} from 'aws-amplify/auth';
@@ -297,7 +296,7 @@ export function signInActor({ services }: SignInMachineOptions) {
297296
return resetPassword({ username });
298297
},
299298
handleResendSignUpCode({ username }) {
300-
return resendSignUpCode({ username });
299+
return services.handleResendSignUpCode({ username });
301300
},
302301
handleSignIn({ formValues, username }) {
303302
const { password } = formValues;

packages/ui/src/machines/authenticator/actors/signUp.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { createMachine, sendUpdate } from 'xstate';
33
import {
44
autoSignIn,
55
ConfirmSignUpInput,
6-
resendSignUpCode,
76
signInWithRedirect,
87
fetchUserAttributes,
98
} from 'aws-amplify/auth';
@@ -287,7 +286,7 @@ export function signUpActor({ services }: SignUpMachineOptions) {
287286
return services.handleConfirmSignUp(input);
288287
},
289288
resendSignUpCode({ username }) {
290-
return resendSignUpCode({ username });
289+
return services.handleResendSignUpCode({ username });
291290
},
292291
signInWithRedirect(_, { data }) {
293292
return signInWithRedirect(data);

packages/ui/src/machines/authenticator/defaultServices.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
confirmSignIn,
77
confirmSignUp,
88
getCurrentUser,
9+
resendSignUpCode,
910
resetPassword,
1011
signIn,
1112
signUp,
@@ -89,6 +90,7 @@ export const defaultServices = {
8990
handleConfirmSignUp: confirmSignUp,
9091
handleForgotPasswordSubmit: confirmResetPassword,
9192
handleForgotPassword: resetPassword,
93+
handleResendSignUpCode: resendSignUpCode,
9294

9395
// Validation hooks for overriding
9496
async validateCustomSignUp(

0 commit comments

Comments
 (0)