AWS Cognito: how to limit user sign up / can only sign up upon invitation?

Viewed 371

I am using AWS Cognito as my Auth server.

My business logic is such that users can only sign up when they are invited (by email). Is this possible?

The flow I have in mind is:

  1. Organization admin sends invitation emails to employees of this organization.

  2. The employees click the invitation link in the email, and are directed to a sign up page. The organization name is preset, so that a user's organization is pre-determined. Since the user click this particular invitation link (sent from this particular organization), the organization name is already determined in the sign-up page.

  3. The employee completes sign-up page and a user is generated in the Cognito user pool, and the newly created user is attached to the organization.

It seems to me that such logic is not possible, by reading the doc:

User accounts are added to your user pool in one of the following ways:

- The user signs up in your user pool's client app, which can be a mobile or web app.

- You can import the user's account into your user pool. For more information, see Importing users into user pools from a CSV file.

- You can create the user's account in your user pool and invite the user to sign in. For more information, see Creating user accounts as administrator.

I hope I'm wrong though.

Did I miss something? Can this be done?

1 Answers

You can create a front end and an API/backend to achieve this.

  1. In cognito settings select "Only allow administrators to create users".
  2. Create a front end for collecting information required for user pool.
  3. Create API that will pass this info to lambda which will use admin_create_user and any other admin_ call that you need.

You will then send your front end's link to certain users you want to invite. Make sure these are unique and have expiration time. You can also make it so that a link can only be used to sign up a single user.

Related