[**Documentation**](../../../README)

***

[Documentation](../../../README) / [zerotal](../../README) / [auth](../README) / tokenCan

# Function: tokenCan()

> **tokenCan**(`row`, `ability`): `boolean`

Defined in: [packages/auth/src/PersonalAccessToken.ts:147](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/auth/src/PersonalAccessToken.ts#L147)

Check whether a token grants a specific ability (scope).

## Parameters

### row

[`TokenRow`](../interfaces/TokenRow)

The stored token row (as loaded by [BearerTokenMiddleware](../classes/BearerTokenMiddleware)).

### ability

`string`

The ability name to check for, e.g. `"write"`.

## Returns

`boolean`

`true` when the token may perform `ability`.

## Remarks

A `null` abilities column or the wildcard `['*']` is treated as full access.
If the stored `abilities` JSON fails to parse, this fails **closed** (returns
`false`) rather than granting access.
