Hello , I am trying to work with VUE Spa Applications + Laravel .
I am trying to recuparate the user detalhes that is Logged In , in the Controller becose when I have to add a POST , I need the ID of the USER that is creating this POST .
I am making the Auth with JWT class , like this example -
https://www.youtube.com/watch?v=Jd1RW-0lQOs&list=PLJpBh2VJhy5wPhAmjDB42pkHUnqolqxxq
it is working , it makes the authenticaton , and return the user detale ,to front ( VUE ).
I have those credentias in the VUE , but I dont want to pass those informations by Javascript to the BACK .
this is my authentication -
use Auth;
if(auth()->guard('api')->attempt($credentials)){
// SUCCESSS
}
I am tryng to recuparete the user like this -
$user = Auth::guard('api')->user();
dd($user) ; // null
or
$user = Auth::guard('api');
dd($user) ;
// result ->
JWTGuard {#280 ▼
#lastAttempted: null
#jwt: JWT {#286 ▶}
#request: Request {#43 ▶}
#user: null
#provider: EloquentUserProvider {#317 ▶}
}
How could I recuparate the user ID in my controller ? is that a correct approutch ?