You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/pages/[platform]/build-a-backend/auth/connect-your-frontend/multi-step-sign-in/index.mdx
+87Lines changed: 87 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -80,6 +80,21 @@ if (nextStep.signInStep === 'CONTINUE_SIGN_IN_WITH_TOTP_SETUP') {
80
80
});
81
81
}
82
82
83
+
if (nextStep.signInStep==='CONFIRM_SIGN_IN_WITH_PASSWORD') {
84
+
// collect password from user
85
+
awaitconfirmSignIn({
86
+
challengeResponse: 'hunter2',
87
+
});
88
+
}
89
+
90
+
if (nextStep.signInStep==='CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTION') {
91
+
// present nextStep.availableChallenges to user
92
+
// collect user selection
93
+
awaitconfirmSignIn({
94
+
challengeResponse: 'SMS_OTP', // or 'EMAIL_OTP', 'WEB_AUTHN', 'PASSWORD', 'PASSWORD_SRP'
95
+
});
96
+
}
97
+
83
98
if (nextStep.signInStep==='CONFIRM_SIGN_IN_WITH_CUSTOM_CHALLENGE') {
84
99
// collect custom challenge answer from user
85
100
awaitconfirmSignIn({
@@ -361,6 +376,78 @@ async function handleMfaSelection(mfaType: MfaType) {
361
376
362
377
```
363
378
379
+
## Confirm sign-in with Password
380
+
381
+
If the next step is `CONFIRM_SIGN_IN_WITH_PASSWORD`, the user must provide their password as the first factor authentication method. To handle this step, your implementation should prompt the user to enter their password. After the user enters the password, pass the value to the `confirmSignIn` API.
const result =awaitconfirmSignIn({ challengeResponse: password });
398
+
399
+
returnhandleSignInResult(result);
400
+
}
401
+
```
402
+
403
+
## Continue sign-in with First Factor Selection
404
+
405
+
If the next step is `CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTION`, the user must select a first factor method for authentication. After the user selects an option, your implementation should pass the selected method to the `confirmSignIn` API.
406
+
407
+
The first factor types which are currently supported by Amplify Auth are:
408
+
-`SMS_OTP`
409
+
-`EMAIL_OTP`
410
+
-`WEB_AUTHN`
411
+
-`PASSWORD`
412
+
-`PASSWORD_SRP`
413
+
414
+
Depending on your configuration and what factors the user has previously setup, not all options may be available. Only the available options will be presented in `availableChallenges` for selection.
415
+
416
+
Once Amplify receives the user's selection via the `confirmSignIn` API, you can expect to handle a follow up `nextStep` corresponding with the first factor type selected:
417
+
- If `SMS_OTP` is selected, `CONFIRM_SIGN_IN_WITH_SMS_CODE` will be the next step.
418
+
- If `EMAIL_OTP` is selected, `CONFIRM_SIGN_IN_WITH_EMAIL_CODE` will be the next step.
419
+
- If `PASSWORD` or `PASSWORD_SRP` is selected, `CONFIRM_SIGN_IN_WITH_PASSWORD` will be the next step.
420
+
- If `WEB_AUTHN` is selected, Amplify Auth will initiate the authentication ceremony on the user's device. If successful, the next step will be `DONE`.
const result =awaitconfirmSignIn({ challengeResponse: firstFactorType });
445
+
446
+
returnhandleSignInResult(result);
447
+
}
448
+
449
+
```
450
+
364
451
## Confirm sign-in with custom challenge
365
452
366
453
If the next step is `CONFIRM_SIGN_IN_WITH_CUSTOM_CHALLENGE`, Amplify Auth is awaiting completion of a custom authentication challenge. The challenge is based on the AWS Lambda trigger you configured as part of a custom sign in flow.
Copy file name to clipboardExpand all lines: src/pages/[platform]/build-a-backend/auth/connect-your-frontend/switching-authentication-flows/index.mdx
+34-15Lines changed: 34 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -148,18 +148,9 @@ await signIn({
148
148
149
149
## USER_AUTH flow
150
150
151
-
The `USER_AUTH` sign in flow will support the following methods of first factor authentication: `WEB_AUTHN`, `EMAIL_OTP`, `SMS_OTP`, `PASSWORD`, and `PASSWORD_SRP`.
151
+
The `USER_AUTH` sign in flow supports the following methods as first factors for authentication: `WEB_AUTHN`, `EMAIL_OTP`, `SMS_OTP`, `PASSWORD`, and `PASSWORD_SRP`.
152
152
153
-
```ts
154
-
typeAuthFactorType=
155
-
|"WEB_AUTHN"
156
-
|"EMAIL_OTP"
157
-
|"SMS_OTP"
158
-
|"PASSWORD"
159
-
|"PASSWORD_SRP";
160
-
```
161
-
162
-
If the desired first factor is known before the sign in flow is initiated it can be passed to the initial sign in call.
153
+
If the desired first factor is known when authentication is initiated, it can be passed to the `signIn` API as the `preferredChallenge` to initiate the corresponding authentication flow.
preferredChallenge: "WEB_AUTHN"// or "EMAIL_OTP" or "SMS_OTP"
185
176
},
186
177
});
187
178
```
188
179
189
-
If the desired first factor is not known, the flow will continue to select an available first factor.
180
+
If the desired first factor is not known or you would like to provide users with the available options, `preferredChallenge` can be omitted from the initial `signIn` API call.
181
+
182
+
This allows you to discover which authentication first factors are available for a user via the `CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTION` step. You can then present the available options to the user and use the `confirmSignIn` API to respond with the user's selection.
challengeResponse: 'SMS_OTP', // or 'EMAIL_OTP', 'WEB_AUTHN', 'PASSWORD', 'PASSWORD_SRP'
201
+
});
202
+
}
203
+
204
+
```
205
+
Also, note that if the `preferredChallenge` passed to the initial `signIn` API call is unavailable for the user, Amplify will also respond with the `CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTION` next step.
206
+
190
207
191
-
> For more information about determining a first factor, and signing in with passwordless authorization factors, please visit the [concepts page for passwordless](/[platform]/build-a-backend/auth/concepts/passwordless/)
208
+
<Callout>
209
+
For more information about determining a first factor, and signing in with passwordless authentication factors, please visit the [Passwordless](/[platform]/build-a-backend/auth/concepts/passwordless/) concepts page.
0 commit comments