Logging in users
A user must be logged in before they can start making actions (uploading, annotating, etc).
There are three ways to login a user. One is with a username & password, one is with an authentication token, and you can also log users in anonymously.
#
Username and passwordTo login a user with a username and password, you can use the loginWithPassword
function.
The username and password provided will be passed into your verifyPassword
function on the server. If the username and password are valid, the user will be logged in. If they are not, the promise will be rejected with an error.
This function resolves to a User
object that you can use to manage documents.
#
Authentication tokenYou can also login a user using an authentication token via the loginWithToken
function.
This function will pass the authentication token into your getUserFromToken
function on the server. If the token is valid, the user will be logged in, otherwise the promise will be rejected with an error.
If you need to pass multiple tokens, you can stringify an object and send it to the server, and then parse the JSON in your getUserFromToken
function.
This function resolves to a User
object that you can use to manage documents.
#
AnonymouslyTo log in a user anonymously, see this guide.
#
Logging out usersA user can be logged out with the User.logout API.
#
TroubleshootingIf you are experiencing issues setting up user authentication, we recommend enabling authentication specific debug logs on both the server and client:
Once enabled, logs related to authentication can be seen in both your server and client consoles. These logs can provide insight into what might be going wrong.