Skip to content

Commit

Permalink
expand autosignin examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jjarvisp committed Nov 27, 2024
1 parent a456563 commit 8e52a2e
Showing 1 changed file with 32 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ Your application's users can also sign up using passwordless methods. To learn m
```typescript
// Sign up using a phone number
const { nextStep: signUpNextStep } = await signUp({
username: 'james',
username: 'hello',
options: {
userAttributes: {
phone_number: '+15555551234',
Expand All @@ -566,7 +566,7 @@ if (signUpNextStep.signUpStep === 'CONFIRM_SIGN_UP') {

// Confirm sign up with the OTP received
const { nextStep: confirmSignUpNextStep } = await confirmSignUp({
username: 'james',
username: 'hello',
confirmationCode: '123456',
});

Expand Down Expand Up @@ -691,10 +691,10 @@ func confirmSignUp(for username: String, with confirmationCode: String) -> AnyCa
```typescript
// Sign up using an email address
const { nextStep: signUpNextStep } = await signUp({
username: 'james',
username: 'hello',
options: {
userAttributes: {
email: 'james@example.com',
email: 'hello@example.com',
},
},
});
Expand All @@ -714,7 +714,7 @@ if (signUpNextStep.signUpStep === 'CONFIRM_SIGN_UP') {

// Confirm sign up with the OTP received
const { nextStep: confirmSignUpNextStep } = await confirmSignUp({
username: 'james',
username: 'hello',
confirmationCode: '123456',
});

Expand Down Expand Up @@ -837,19 +837,44 @@ func confirmSignUp(for username: String, with confirmationCode: String) -> AnyCa
<InlineFilter filters={["angular", "javascript", "nextjs", "react", "react-native", "vue"]}>

```typescript
// Confirm sign up with the OTP received and auto sign in
// Call `signUp` API with `USER_AUTH` as the authentication flow type for `autoSignIn`
const { nextStep: signUpNextStep } = await signUp({
username: 'hello',
options: {
userAttributes: {
email: '[email protected]',
phone_number: '+15555551234',
},
autoSignIn: {
authFlowType: 'USER_AUTH',
},
},
});

if (signUpNextStep.signUpStep === 'CONFIRM_SIGN_UP') {
console.log(
`Code Delivery Medium: ${signUpNextStep.codeDeliveryDetails.deliveryMedium}`,
);
console.log(
`Code Delivery Destination: ${signUpNextStep.codeDeliveryDetails.destination}`,
);
}

// Call `confirmSignUp` API with the OTP received
const { nextStep: confirmSignUpNextStep } = await confirmSignUp({
username: 'james',
username: 'hello',
confirmationCode: '123456',
});

if (confirmSignUpNextStep.signUpStep === 'COMPLETE_AUTO_SIGN_IN') {
// Call `autoSignIn` API to complete the flow
const { nextStep } = await autoSignIn();

if (nextStep.signInStep === 'DONE') {
console.log('Successfully signed in.');
}
}

```
</InlineFilter>
<InlineFilter filters={["android"]}>
Expand Down

0 comments on commit 8e52a2e

Please sign in to comment.