User management
If you want to use the default database to manage your users, we provide some utility APIs to help achieve this. If you need any flexibility beyond what we provide, you should consider setting up your own database for user management.
#
Creating usersnote
Please note that this is an API for creating users in your database with a username and password. If you have your own user database set up, you should not use these apis.
If you are looking to create an anonymous user, please follow this guide.
To create a user, use the createUser API.
createUser(user): Promise<DatabaseUser>
#
user
(object) information about the user to createemail
(string) the users emailpassword
(string) the users hashed password. Do not store plain text passwords!userName
(string) the users username. Optional.
Returns a DatabaseUser entity..
To use this API its recommended to set up your own endpoint (probably using express
).
Example
#
Getting usersThere are three ways to get user data, documented below.
getUser(id): Promise<DatabaseUser>
#
id
(string) the users id
Gets a user by their ID.
Resolves with a DatabaseUser entity.
getUserByEmail(email): Promise<DatabaseUser>
#
email
(string) the email of the user
Gets a user by their email.
Resolves with a DatabaseUser entity.
getUserByUsername(username): Promise<DatabaseUser>
#
username
(string) the username of the user
Gets a user by their username.
Resolves with a DatabaseUser entity.
#
Editing usersYou can use the following APIs to edit and disable a user.
editUser(user): Promise<DatabaseUser>
#
user
(DatabaseUser) the information to edit. Onlyid
is required to identify the user you want to edit, all other fields are optional. Only fields you pass in will be updated.
Resolves with the updated DatabaseUser
deactivateUser(id): Promise<DatabaseUser>
#
id
(string) the Id of the user to deactivate
Sets a users status to INACTIVE
Resolvers with the updated DatabaseUser entity.
#
Database entities#
DatabaseUserA database user entity is an object with the following shape. Properties with a ?
are optional (but recommended).