2

Sanctum makes it possible, when creating a token, to specify the model to which this token belongs - in the table, the tokenable_type field.
For example:

tokenable_type
App\Models\User
App\Models\User
App\Models\User
App\Models\Group

I wanted Sanctum to only check the token that belongs to a specific model for example Group is this possible?

Markus Meyer
  • 3,327
  • 10
  • 22
  • 35
KordDEM
  • 177
  • 10
  • when tokens are pulled by sanctum, it is pulled using the HasApIToken Models and since it uses the concept of morphs, it only pull morph type against the guard you are currently using . so a guard using user provider will pull Users Morph, and a provider using Groups will pull using Group morphs – Stanley Aloh Aug 01 '22 at 12:02

0 Answers0