/auth
Search
K
Comment on page

hasRoleToken( )

Function to check whether the user has the specific role by a SlashAuth token. If the token does not have that role associated with it, the function returns an error.

Usage

const { data } = await client.user.hasRoleToken({
token: 'eyJhbGc....-nQdQ',
role: 'Member',
});
console.log('HasRole: ', data?.hasRole);

Return Value

{
data?: {
hasRole: boolean;
};
error: ErrorMessage | null;
headers: Object;
statusCode: number;
}

Configuration

token

String that represents a token.
const { data } = await client.user.hasRoleToken({
token: 'eyJhbGc....-nQdQ',
role: 'Member',
});
console.log('HasRole: ', data?.hasRole);

role

String that represents a role.
const { data } = await client.user.hasRoleToken({
token: 'eyJhbGc....-nQdQ',
role: 'Member',
});
console.log('HasRole: ', data?.hasRole);

organizationID (optional)

String that represents an organization's ID.
const { data } = await client.user.hasRoleToken({
token: 'eyJhbGc....-nQdQ',
role: 'Member',
organizationID: 'org.abc',
});
console.log('HasRole: ', data?.hasRole);

Output(s)

Output
Type
hasRole
Boolean