Not getting logged In user in api controller
I want to get logged In a user in the API controller. But getting Null
I have a route in API of the controller in which i want to show
I'm not using JWT, Passport library for that Simple controllers in API and using in the Vuejs
What are you passing in the Request to identify the user?
Thanks, @tykus for replying to me.
I'm using this in the API controller
use Auth;
$currentUser = Auth::user()->id;
\Log::info($currentUser )
but getting null value
What is in the Request to identify the User? You need a token, do you have one?
Bro I want to logged-in user in API controller I have not token
I have put token in session when logged in the user but session value is also coming null in API controller methods
I'm not using any JSON library like JWT & passport for storing
I want loggedin user in the API route controller in web route controller coming but in API route controller not coming user
you need to either move the Route into the web routes file so that the Session is available, or make the session available to the api route groups
Dear can you give me an example how can I make the session available to the API route groups
Take a look at the middlewares associated with the web group in the http Kernel class, and add the Session/Auth ones to the api group
If you don't want to use passport or JWT and just send request from Vuejs from the logged in user's session, then you should move the route to web.php
API routes are STATELESS. There is no concept of an authenticated user
Please or to participate in this conversation.