Laravel fortify endpoint `user/password` change middleware to sanctum

76 Views Asked by At

Fortify already has a route for changing password of a user

 PUT             api/user/password .. user-password.update › Laravel\Fortify › PasswordController@update
                  ⇂ api
                  ⇂ App\Http\Middleware\Authenticate:web

I am using sanctum to authenticate the user. I tried changing the fortify config middleware to

'middleware' => ['api', 'auth:sanctum'],

Now when I try to view the route list with verbose I got

  PUT             api/user/password .. user-password.update › Laravel\Fortify › PasswordController@update
                  ⇂ api
                  ⇂ App\Http\Middleware\Authenticate:sanctum
                  ⇂ App\Http\Middleware\Authenticate:web

But when I hit the endpoint using PUT request api/user/password I get "message": "Unauthenticated." status even I got the correct bearer token I just generated.

Can someone tell me what needs to be done or what I did wrong? Thanks in advance.

0

There are 0 best solutions below