9

I'm currently using AWS Amplify auth, using Cognito for React authentication. User sign-ups must confirm their new account by clicking on a confirmation link they receive via email.

When a submits their sign-up info, the next UI that is displayed is Confirm Signup that asks the user to confirm a code. I do not need this stage, as this is handled when the user confirms their email.

I'm using the react-ui Amplify components to control authentication and user signup/in/out.

import React from "react";
import "./App.css";
import { BrowserRouter as Router } from "react-router-dom";
import "bootstrap/dist/css/bootstrap.min.css";
import { Container } from "react-bootstrap";
import NavBar from "./components/NavBar.js";

import {
  AmplifyAuthenticator,
  AmplifySignUp,
  AmplifyConfirmSignUp,
  AmplifySignOut,
} from "@aws-amplify/ui-react";

import RouteContainer from "./components/RouteContainer";

function App() {
  return (
    <div>
      <AmplifyAuthenticator usernameAlias="email">
        <AmplifySignUp
          slot="sign-up"
          usernameAlias="email"
          formFields={[
            {
              type: "email",
              label: "Enter your email",
              placeholder: "Enter your email",
              required: true,
            },
            {
              type: "password",
              label: "Enter your password",
              placeholder: "",
              required: true,
            },
            {
              type: "custom:postcode",
              label: "Enter your postcode",
              placeholder: "",
              required: true,
            },
          ]}
        >
          <AmplifyConfirmSignUp/>

        </AmplifySignUp>
        <AmplifySignOut />
        <Router>
          <Container>
            <RouteContainer />
          </Container>
        </Router>
        <NavBar />
      </AmplifyAuthenticator>
    </div>
  );
}

export default App;

Is there a prop I can pass to disable <AmplifyConfirmSignUp/> or another way to disable this from the standard sign-up flow?

Thanks.

Brad
  • 109
  • 1
  • 4

2 Answers2

7

You can disable verification in Cognito panel.

  1. Go to https://console.aws.amazon.com/cognito/
  2. Click on "Manage User Pools"
  3. In "General settings" click on "MFA and verifications"
  4. Under "Which attributes do you want to verify?" choose "No verification"
MarkoR
  • 543
  • 4
  • 12
1

You can auto-confirm the user using a lambda function. Here's the documentation

  • Create a lambda function (See Docs) and return autoConfirmUser in the response.
exports.handler = async (event, _context, callback) => {
  console.log(`EVENT: ${JSON.stringify(event)}`);
  event.response.autoConfirmUser = true;
  callback(null, event);
};
  • Attach your lambda function with the Pre Sign-up Lambda Trigger

enter image description here

There's one caveat though, if the user forgets his/her password. He wouldn't be able to recover it. So keep it in mind. Here's more about this on Github

I hope it helps :)

Credits

Anurag Bhagsain
  • 363
  • 3
  • 10