Create a user

A basic user account in Adamite just needs an email and a password.

await adamite().auth().createUser("email@domain.com", "password");

Once you call the createUser method, and the user account is created, the user will be automatically signed in to that account.

Storing additional user data

The Adamite authentication system only stores basic information about an account, such as its email address, when it was last logged in, etc. To store additional information about a user, we suggest creating a users table in the database. To make this process easier, we let you provide a post-registration callback where you can create additional user data in the database.

await adamite()
  .auth()
  .createUser("email@email.com", "password", async (user) => {
    await adamite()
      .database()
      .collection("users")
      .create({ id: user.id, name: "John Smith", picture: "..." });
  });

The user won't be signed in to their new account until the post-registration callback resolves. This allows you to safely assume user data exists in the database once a user is logged in assuming you create that data in the post registration callback.

Prevent automatic login

If you'd like to create an account without automatically logging the user in, you can pass a fourth parameter to the createUser method to bypass this functionality.

await adamite()
  .auth()
  .createUser("email@email.com", "password", null, true);

Last updated