laravellaravel-passportlaravel-admin

Laravel authentication API and web


I have API for frontend and admin part for web. The user is authenticated on the API of the frontend using a passport. The user can get the role - admin. How to give user access to the admin area if it is authenticated already with a passport?

How to make so that the user who logged in through the passport had access to the admin panel? At the moment there is no user in the session if I tried to log in to the admin part.


Solution

  • If your token is accessible when you are authenticating and or you save the token in the database, you can use the token to find the user and get the user's id and auth()->loginUsingId($user_id)