Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

confirmSignUp does not return a response when called after 'signIn' returns with 'CONFIRM_SIGN_UP' status #13876

Open
3 tasks done
abduaddis1 opened this issue Oct 2, 2024 · 0 comments
Assignees
Labels
Auth Related to Auth components/category pending-maintainer-response Issue is pending a response from the Amplify team. pending-triage Issue is pending triage

Comments

@abduaddis1
Copy link

abduaddis1 commented Oct 2, 2024

Before opening, please confirm:

JavaScript Framework

React Native

Amplify APIs

Authentication

Amplify Version

v6

Amplify Categories

auth

Backend

Amplify CLI

Environment information

# Put output below this line
  System:
    OS: macOS 14.3
    CPU: (8) arm64 Apple M2
    Memory: 85.14 MB / 24.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.8.0 - /opt/homebrew/bin/node
    Yarn: 3.6.4 - /opt/homebrew/bin/yarn
    npm: 10.8.2 - /opt/homebrew/bin/npm
    Watchman: 2024.09.02.00 - /opt/homebrew/bin/watchman
  Browsers:
    Brave Browser: 128.1.69.162
    Edge: 129.0.2792.65
  npmPackages:
    @aws-amplify/react-native: ^1.1.4 => 1.1.4 
    @aws-amplify/ui-react-native: ^2.2.5 => 2.2.5 
    @babel/core: ^7.20.0 => 7.24.5 
    @expo-google-fonts/manrope: ^0.2.3 => 0.2.3 
    @react-native-async-storage/async-storage: ^1.24.0 => 1.24.0 
    @react-native-community/netinfo: ^11.1.0 => 11.1.0 
    @react-navigation/native: ^6.1.6 => 6.1.17 
    @react-navigation/native-stack: ^6.11.0 => 6.11.0 (6.9.26)
    @react-navigation/stack: ^6.4.1 => 6.4.1 
    @types/react: ~18.2.45 => 18.2.79 
    @types/react-native-background-timer: ^2.0.2 => 2.0.2 
    @types/react-native-snap-carousel: ^3.8.11 => 3.8.11 
    HelloWorld:  0.0.1 
    aws-amplify: ^6.0.18 => 6.5.1 
    aws-amplify/adapter-core:  undefined ()
    aws-amplify/analytics:  undefined ()
    aws-amplify/analytics/kinesis:  undefined ()
    aws-amplify/analytics/kinesis-firehose:  undefined ()
    aws-amplify/analytics/personalize:  undefined ()
    aws-amplify/analytics/pinpoint:  undefined ()
    aws-amplify/api:  undefined ()
    aws-amplify/api/server:  undefined ()
    aws-amplify/auth:  undefined ()
    aws-amplify/auth/cognito:  undefined ()
    aws-amplify/auth/cognito/server:  undefined ()
    aws-amplify/auth/enable-oauth-listener:  undefined ()
    aws-amplify/auth/server:  undefined ()
    aws-amplify/data:  undefined ()
    aws-amplify/data/server:  undefined ()
    aws-amplify/datastore:  undefined ()
    aws-amplify/in-app-messaging:  undefined ()
    aws-amplify/in-app-messaging/pinpoint:  undefined ()
    aws-amplify/push-notifications:  undefined ()
    aws-amplify/push-notifications/pinpoint:  undefined ()
    aws-amplify/storage:  undefined ()
    aws-amplify/storage/s3:  undefined ()
    aws-amplify/storage/s3/server:  undefined ()
    aws-amplify/storage/server:  undefined ()
    aws-amplify/utils:  undefined ()
    expo: ^50.0.0 => 50.0.19 (51.0.28)
    expo-app-loading: ^2.1.1 => 2.1.1 
    expo-av: ~13.10.5 => 13.10.6 
    expo-blur: ~12.9.2 => 12.9.2 
    expo-cached-image: ^51.0.19 => 51.0.19 
    expo-constants: ~15.4.6 => 15.4.6 (16.0.2)
    expo-file-system: ~16.0.9 => 16.0.9 (17.0.1)
    expo-font: ~11.10.3 => 11.10.3 (12.0.9)
    expo-image: ~1.10.6 => 1.10.6 
    expo-image-picker: ~14.7.1 => 14.7.1 
    expo-linear-gradient: ^12.7.2 => 12.7.2 
    expo-linking: ~6.2.2 => 6.2.2 
    expo-router: ~3.4.10 => 3.4.10 
    expo-status-bar: ~1.11.1 => 1.11.1 
    expo-video-thumbnails: ~7.9.0 => 7.9.0 
    expo-web-browser: ~12.8.2 => 12.8.2 
    install: ^0.13.0 => 0.13.0 
    phosphor-react-native: ^2.2.0 => 2.2.0 
    react: 18.2.0 => 18.2.0 
    react-native: 0.73.6 => 0.73.6 
    react-native-background-timer: ^2.4.1 => 2.4.1 
    react-native-confirmation-code-field: ^7.4.0 => 7.4.0 
    react-native-gesture-handler: ~2.14.0 => 2.14.1 
    react-native-get-random-values: ~1.9.0 => 1.9.0 
    react-native-image-crop-picker: ^0.41.2 => 0.41.2 
    react-native-image-picker: ^7.1.2 => 7.1.2 
    react-native-modal: ^13.0.1 => 13.0.1 
    react-native-reanimated: ~3.6.2 => 3.6.3 
    react-native-reanimated-carousel: ^3.5.1 => 3.5.1 
    react-native-responsive-screen: ^1.4.2 => 1.4.2 
    react-native-safe-area-context: 4.8.2 => 4.8.2 
    react-native-screens: ~3.29.0 => 3.29.0 
    react-native-size-matters: ^0.4.2 => 0.4.2 
    react-native-snap-carousel: ^3.9.1 => 3.9.1 
    react-native-splash-screen: ^3.3.0 => 3.3.0 
    react-native-svg: 14.1.0 => 14.1.0 
    react-native-svg-transformer: ^1.5.0 => 1.5.0 
    react-native-toast-message: ^2.2.0 => 2.2.0 
    react-native-vector-icons: ^10.2.0 => 10.2.0 
    react-native-webview: ^13.6.4 => 13.6.4 
    responsive-screen:  0.1.0 
    responsive-screen-orientation-change:  0.1.0 
    responsive-screen-styled-components:  0.1.0 
    typescript: ^5.5.4 => 5.5.4 
    uuid: ^10.0.0 => 10.0.0 (9.0.1, 8.3.2, 7.0.3)
    uuidv4: ^6.2.13 => 6.2.13 
  npmGlobalPackages:
    @aws-amplify/cli: 12.10.1
    @expo/ngrok: 4.1.3
    eas-cli: 10.1.1
    expo-cli: 6.3.10
    npm-check: 6.0.1
    npm: 10.8.2
    pod-install: 0.2.2
    react-native-cli: 2.0.1
    typescript: 5.5.4


Describe the bug

I have a screen where a user can sign up or sign in to my application. The users username is their email. After the user signs up, or if the user signs in and the 'nextStep.signInStep' value is 'CONFIRM_SIGN_UP', the user is redirected to a screen where they can enter a confirmation code. This screen calls 'confirmSignUp' with the users email and the confirmation code; the only difference is, if called after 'signUp' it also calls 'autoSignIn' and if called after 'signIn' it does not.

My code for the logic of the confirmation of the signup is as follows:

 const onSubmitSignedIn = async () => {
    setLoading(true);
    console.log("Submitting OTP: ", confirmationCode);
    try {
      const response = await confirmSignUp({
        username: userEmail || '',
        confirmationCode: confirmationCode || ''
      });
      console.log("Sign up after sign in complete: ", response);

      router.push({
        pathname: 'UserAuthentication/CreatePassword',
        params: {
          userEmail: userEmail,
          userId: userId,
        }
      });
    } catch (error) {
      setOtpStatus({valid: false, message: "There was an error confirming your code; please try again or contact support"});
      console.log("Error submitting OTP: ", JSON.stringify(error));
    } finally {
      setLoading(false);
    }
  };

  const onSubmitSignedUp = async () => {
    setLoading(true);
    console.log("Submitting OTP: ", confirmationCode);
    try {
      console.log("User email: ", userEmail)
      console.log("Confrimation code: ", confirmationCode)
      const response = await confirmSignUp({
        username: userEmail || '',
        confirmationCode: confirmationCode || ''
      });
      console.log("confirmSignUp response: ", response);

      const {isSignUpComplete, nextStep} = response;
      console.log("Sign up complete");
      const {isSignedIn} = await autoSignIn();
      console.log("Autosignin response: ", JSON.stringify(isSignedIn));

      router.push({
        pathname: 'UserAuthentication/CreatePassword',
        params: {
          userEmail: userEmail,
          userId: userId,
        }
      });
    } catch (error) {
      setOtpStatus({valid: false, message: "There was an error confirming your code; please try again or contact support"});
      console.log("Error submitting OTP: ", JSON.stringify(error));
    } finally {
      setLoading(false);
    }
  };

  const onSubmitOtp = async () => {
    if (confirmationCode.length !== 6) {
      setOtpStatus({valid: false, message: "Please enter a 6-digit code"});
      return;
    }
    
    if(shouldAutoSignIn === "true") {
      await onSubmitSignedUp();
    } else {
      await onSubmitSignedIn();
    }
  };

I am getting a weird issue however; if I call 'confirmSignUp' after a user has signed up (user signs up -> verification code screen) everything works fine, and the response logs as expected; but when I call sign in and I am returned a 'CONFIRM_SIGN_UP' next step (signUp -> verification code screen -> swipe up and out of application -> restart application -> signIn with credentials -> get 'CONFIRM_SIGN_UP' status from signIn -> verification code screen -> confirmSignUp) there seems to be no response; console.log("Sign up after sign in complete: ", response); is not logged, and nothing after 'await confirmSignUp' happens; however, if I use an incorrect code, I do get a log saying it is a '{"name":"CodeMismatchException"}' error. Additionally, the confirmation does seem to happen if the 'confirmSignUp' function is run with the correct code, as the user will show up as verified in the Cognito user pool in the aws console. I do not understand why the confirmSignUp does not seem to return anything or blocks the rest of my code if it is called with the correct verification code however.

Expected behavior

The confirmSignUp function should run properly and I should get a response from confirmSignUp of type confirmSignUpOutput.

Reproduction steps

  1. Create a bare react native application setup with a bare AWS amplify configuration.
  2. Add amplify authentication
  3. Call the signUp function, do not verify with confirmSignUp, then attempt to sign in and verify user after 'CONFIRM_SIGN_UP' is returned.

Code Snippet

// Put your code below this line.

Log output

// Put your logs below this line


aws-exports.js

/* eslint-disable */
// WARNING: DO NOT EDIT. This file is automatically generated by AWS Amplify. It will be overwritten.

const awsmobile = {
    "aws_project_region": "us-east-1",
    "aws_cognito_identity_pool_id": "us-east-1:e86e9a7b-XXXXX",
    "aws_cognito_region": "us-east-1",
    "aws_user_pools_id": "us-east-1XXXXXXX",
    "aws_user_pools_web_client_id": "745rq15akuktdXXXXXXX",
    "oauth": {},
    "aws_cognito_username_attributes": [
        "EMAIL"
    ],
    "aws_cognito_social_providers": [],
    "aws_cognito_signup_attributes": [
        "EMAIL"
    ],
    "aws_cognito_mfa_configuration": "OFF",
    "aws_cognito_mfa_types": [
        "SMS"
    ],
    "aws_cognito_password_protection_settings": {
        "passwordPolicyMinLength": 8,
        "passwordPolicyCharacters": []
    },
    "aws_cognito_verification_mechanisms": [
        "EMAIL"
    ],
    "aws_cloud_logic_custom": [
        {
            "name": "XXXXi",
            "endpoint": "XXXXXX",
            "region": "us-east-1"
        },
        {
            "name": "XXXX",
            "endpoint": "XXXX",
            "region": "us-east-1"
        },
        {
            "name": "XXXX",
            "endpoint": "XXXXX",
            "region": "us-east-1"
        },
        {
            "name": "XXXXXX",
            "endpoint": "XXXXXX",
            "region": "us-east-1"
        },
        {
            "name": "XXXXX",
            "endpoint": "XXXXXX",
            "region": "us-east-1"
        },
        {
            "name": "XXXXX",
            "endpoint": "XXXXX",
            "region": "us-east-1"
        }
    ],
    "aws_user_files_s3_bucket": "iXXXXXXXX",
    "aws_user_files_s3_bucket_region": "us-east-1"
};


export default awsmobile;

Manual configuration

No response

Additional configuration

No response

Mobile Device

iPhone 15

Mobile Operating System

iOS 17.4

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

@github-actions github-actions bot added pending-triage Issue is pending triage pending-maintainer-response Issue is pending a response from the Amplify team. labels Oct 2, 2024
@cwomack cwomack self-assigned this Oct 2, 2024
@cwomack cwomack added the Auth Related to Auth components/category label Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auth Related to Auth components/category pending-maintainer-response Issue is pending a response from the Amplify team. pending-triage Issue is pending triage
Projects
None yet
Development

No branches or pull requests

2 participants