Skip to content
Advertisement

Laravel Auth:api will not persisting

I’m realizing platform web and app that work with Laravel 6 in back-end. I set auth web for platform web and auth api (with Laravel JWT) for the app. When I signin with app, Auth doesn’t persist and with subsequent calls I can’t to refresh the token nor to get user info. The code is below:

routes/api.php

JavaScript

AuthController.php

JavaScript

Kernel middlewares

JavaScript

config auth.php

JavaScript

User model implements JWTSubject. I tryied with Auth:guard(‘api’) and JWTAuth, too. Login works, refresh token doesn’t works and the route “me” returns empty object. Can You help me?

Advertisement

Answer

You should pass token with your post request for me function, security wise it is advisable.

Edit your me function

From :

JavaScript

To:

JavaScript

Refresh function should be

From:

JavaScript

To:

JavaScript

Read More about JWT

Hope this will be useful.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement