Skip to content

How list all token save in database #284

Answered by lonnieezell
caosdp-rs asked this question in Q&A
Discussion options

You must be logged in to vote

Access tokens are really designed to be viewed on a per-user basis so that's the functionality built in.

$tokens = auth()->user()->accessTokens();

However, if you want to grab all tokens for all users, you could do something like:

use  CodeIgniter\Shield\Models\UserIdentityModel;
use CodeIgniter\Shield\Authentication\Authenticators\AccessTokens;

$model = model(UserIdentityModel::class);
$tokens = $model
    ->where('type', AccessTokens::ID_TYPE_ACCESS_TOKEN)
    ->asObject(AccessToken::class)
    ->findAll();

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by caosdp-rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants