- You add the user details in your database
- You create a user in CometChat
- You log in the user to your app
- You log in the user in CometChat (programmatically)
Creating a User
Ideally, user creation should take place at your backend. You can refer our Rest API to learn more about creating a user and use the appropriate code sample based on your backend language. However, if you wish to create users on the fly, you can use thecreateUser() method. This method takes a User object and the Auth Key as input parameters and returns the created User object if the request is successful.
- TypeScript
Updating a user
Updating a user similar to creating a user should ideally be achieved at your backend using the Restful APIs. For more information, you can check the update a user section. However, this can be achieved on the fly as well as using theupdateUser() method. This method takes a User object and the Auth Key as inputs and returns the updated User object on the successful execution of the request.
- JavaScript
User object. See User Class for all available fields.
Updating a User
Like creation, user updates should ideally happen on your backend via the REST API. For client-side updates (development only), useupdateUser():
- TypeScript
- JavaScript
User object has the correct UID set.
Returns a User object. See User Class for all available fields.
Updating Logged-in User
UseupdateCurrentUserDetails() to update the current user without an Auth Key. Note: You cannot update the user’s role with this method.
- TypeScript
- JavaScript
User object.
Deleting a user
Deleting a user can only be achieved via the Restful APIs. For more information please check the delete a user section.User Class
Next Steps
Retrieve Users
Fetch and filter user lists with pagination.
User Presence
Monitor real-time online/offline status.
Block Users
Block and unblock users.
Authentication
Log users into CometChat.