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

React Authenticator confirmSignUp not returning userId #5055

Closed
4 tasks done
isaaccarrington opened this issue Mar 10, 2024 · 2 comments
Closed
4 tasks done

React Authenticator confirmSignUp not returning userId #5055

isaaccarrington opened this issue Mar 10, 2024 · 2 comments
Labels
Authenticator An issue or a feature-request for an Authenticator UI Component

Comments

@isaaccarrington
Copy link

isaaccarrington commented Mar 10, 2024

Before creating a new issue, please confirm:

On which framework/platform are you having an issue?

React

Which UI component?

Authenticator

How is your app built?

Next.js

What browsers are you seeing the problem on?

Chrome, Safari

Which region are you seeing the problem in?

us-east-1

Please describe your bug.

The confirmSignUp function does not return userId. Instead it returns only

{
  isSignUpComplete: true,
  nextStep: { signUpStep: 'COMPLETE_AUTO_SIGN_IN' }
}

What's the expected behaviour?

The output for v6 as described in the auth migration guide:

type ConfirmSignUpOutput = {
    isSignUpComplete: boolean;
    userId?: string | undefined;
    nextStep: {
        signUpStep:
            | 'DONE'
            | 'CONFIRM_SIGN_UP'
            | 'COMPLETE_AUTO_SIGN_IN',
        codeDeliveryDetails: { // Not included when signUpStep is 'DONE'
            destination?: string;
            deliveryMedium?: 
              | 'EMAIL'
              | 'SMS'
              | 'PHONE'
              | 'UNKNOWN';
            attributeName?: UserAttributeKey;
        }
    };
}

Help us reproduce the bug!

Sign up a new user and observe the output of confirmSignUp logged into the browser console.

Code Snippet

// Put your code below this line.
"use client";
import { navigate } from "@/app/utils/actions";
import { Authenticator } from "@aws-amplify/ui-react";
import { confirmSignUp, signUp } from 'aws-amplify/auth';

export default function AuthenticatorWithEmail() {

    const services = {
        async handleSignUp(formData) {
            let { username, password, options } = formData;
            const signUpResult = await signUp({
                username,
                password,
                options,
            });
            return signUpResult
        },
        async handleConfirmSignUp(formdata) {

            let { username, confirmationCode } = formdata;
            try {
                const confirmSignUpResult = await confirmSignUp({
                        username,
                        confirmationCode
                    });
                let { isSignUpComplete, userId, nextStep} = confirmSignUpResult;
                console.log(userId);
                console.log(confirmSignUpResult.userId);
                return confirmSignUpResult
            } catch (error) {
                console.log(error);
            }
        },
    };

    return (
        <Authenticator services={services} initialState="signUp">
            {({ signOut, user }) => (
                <div>
                    <p>Welcome, {user?.userId} : {user?.username}</p>
                    <button onClick={signOut}>Sign out</button>
                    <form action={navigate}>
                        <input type="text" name="id" />
                        <button>Complete profile</button>
                    </form>
                </div>
            )}
        </Authenticator>
    );
}

Console log output

{
  isSignUpComplete: true,
  nextStep: { signUpStep: 'COMPLETE_AUTO_SIGN_IN' }
}

Additional information and screenshots

My relevant dependencies in package.json are:

  "dependencies": {
    "@aws-amplify/adapter-nextjs": "^1.0.17",
    "@aws-amplify/ui-react": "^6.1.4",
    "aws-amplify": "^6.0.17",
    "next": "14.1.0",
    "react": "^18",
  }

Application is running locally with npm run dev.

Workstation is MacBook Pro 14-inch 2021 with M1 Pro chip on macOS Sonoma 14.2.1.

No response

@github-actions github-actions bot added the pending-triage Issue is pending triage label Mar 10, 2024
@isaaccarrington
Copy link
Author

Sorry I raised this in the wrong place, should have been in amplify-js, sigh. Existing bug report

@isaaccarrington
Copy link
Author

As per above

@jordanvn jordanvn added Authenticator An issue or a feature-request for an Authenticator UI Component and removed pending-triage Issue is pending triage labels Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Authenticator An issue or a feature-request for an Authenticator UI Component
Projects
None yet
Development

No branches or pull requests

2 participants