Adamite
  • Initial page
  • Server
    • Introduction
    • Database
      • Configuration
      • Using different adapters
        • Memory Adapter
      • Securing your data
        • Securing read operations
    • Functions
      • Invokable Functions
      • Runtime Functions
      • Scheduled Functions
  • SDK
    • Introduction
    • Database
      • Introduction
      • Read a document
      • Read multiple documents
      • Subscribe to changes
      • Create a new document
      • Update an existing document
      • Delete a document
    • Authentication
      • Create a user
      • Log in and log out
      • Get the logged in user
    • Functions
      • Invoke a function
Powered by GitBook
On this page
  • Storing additional user data
  • Prevent automatic login

Was this helpful?

  1. SDK
  2. Authentication

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);
PreviousAuthenticationNextLog in and log out

Last updated 5 years ago

Was this helpful?