identify
Associate the current session with a user.
This method identifies the user with an identifier that is unique to your application.
This is equivalent to calling the setToken method, but instead of specifying the token, you provide the user ID directly and the SDK generates an unsigned token for you.
If the Require authenticated token option is enabled in the application settings, you need to use the setToken method to provide a signed token instead.
The SDK automatically emits userSignedOut and userSignedIn events when the user identity changes. As a result, if the user ID changes during a session, the current session is terminated and a new session is started.
Note that calling this method issues a new token regardless of whether the specified ID is the same as the current one.
Signature
This method has the following signature:
croct.identify(userId: string): void
Example
Here is a basic example of how to use this method:
import croct from '@croct/plug';croct.identify('00000000-0000-0000-0000-000000000000');
Parameters
The following list describes the supported parameters:
- userIdstring
The ID that uniquely identifies the user in your application.
Although the user ID can be any string, it is recommended to use a string or other globally unique identifier.