isAnonymous

Check whether the user is anonymous.

This method checks whether the current session is anonymous.

A user is anonymous if they have no identifier. Consequently, a token without a subject is also considered anonymous.

Signature

This method has the following signature:

user.isAnonymous(): boolean

This method returns true if the user is anonymous, false otherwise.

Example

Here is a basic example of how to use this method:

import croct from '@croct/plug';
if (croct.user.isAnonymous()) {
console.log('The user is anonymous');
} else {
console.log('The user is identified');
}