How list all token save in database #284
-
| I try use CodeIgniter\Shield\Authentication\Traits\HasAccessTokens;
class Tokens extends BaseController
{
use HasAccessTokens;
public function index()
    { 
        revokeAllAccessTokens();
//listAllAccessTokens();
}
}
 | 
Beta Was this translation helpful? Give feedback.
      
      
          Answered by
          
            lonnieezell
          
      
      
        Jul 5, 2022 
      
    
    Replies: 1 comment
-
| 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(); | 
Beta Was this translation helpful? Give feedback.
                  
                    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
  
        
    
Access tokens are really designed to be viewed on a per-user basis so that's the functionality built in.
However, if you want to grab all tokens for all users, you could do something like: