getting wrong user with laravel sanctum

Viewed 67

I am using Laravel Sanctum to provide a personal access token to my clients. I am using these guards in auth.php:

    'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'users',
        ],

        'client' => [
            'driver' => 'token',
            'provider' => 'clients',
            'hash' => false
        ]
    ],
'providers' => [
        'users' => [
            'driver' => 'eloquent',
            'model' => App\Models\User::class,
        ],

        'clients' => [
            'driver' => 'eloquent',
            'model' => App\Models\Client::class,
        ],
    ],

I give my clients tokens using the following code:

    $client = Client::find($id);
    $token = $client->createToken('CLIENT_TOKEN');

but whenever I try to access the user with $request->user() I get the wrong user. while the token is completely different from what the retrieved user is. I am using laravel-swoole package as my webserver.

0 Answers
Related