keepmoving
keepmoving

Reputation: 2043

How to create AWS Admin User with Unconfirmed state

I am using AWS cognito API to create User in pool. User is being created successfully in Pool. Following is the code for that . But this code create user with FORCE_CHANGE_PASSWORD state but I want to create user in UNCONFIRMED state. Can someone help me on this?

AdminCreateUserRequest cognitoRequest =
        new AdminCreateUserRequest().withUserPoolId(id)
                .withUsername(r.getEmail())
                .withTemporaryPassword(r.getPassword().trim())
                .withUserAttributes(new AttributeType().withName(Constants.EMAIL).withValue(r.getEmail().trim()))
                .withUserAttributes(new AttributeType().withName(Constants.EMAI_VERIFIED).withValue("false"))
                .withUserAttributes(new AttributeType().withName(Constants.GIVEN_NAME).withValue(r.getFirstName().trim()))
                .withUserAttributes(new AttributeType().withName(Constants.FAMILY_NAME).withValue(r.getLastName().trim()));

Upvotes: 3

Views: 1102

Answers (1)

chetan mahajan
chetan mahajan

Reputation: 813

You can use SignUpRequest to create user with unconfirmed status

SignUpRequest request = new SignUpRequest().withClientId(clientId)
                .withUsername(userSignUpRequest.getUsername()).withPassword(userSignUpRequest.getPassword())
                .withUserAttributes(emailAttr, groupAttr);
        return cognitoClient.signUp(request)

After signup, user will get code on the email mentioned during signup.You can confirm user signup using different request taking code from user as input.

Upvotes: 2

Related Questions