tymondesigns / jwt-auth

🔐 JSON Web Token Authentication for Laravel & Lumen
https://jwt-auth.com
MIT License
11.23k stars 1.55k forks source link

GET the user Detail from the controller , when CREATE a POST #1870

Open murilolivorato opened 4 years ago

murilolivorato commented 4 years ago
Q A
Bug? not
New Feature? no / yes
Framework Laravel
Framework version 5.8
Package version 1.0.0
PHP version 7.2

Hello , I am using SWT + Laravel + VUE . I loggin in with my credentials like this -

use Auth;

if($token = auth('api')->attempt($credentials)){
    // SUCCESSS
}

IT is working , but I need to access the user information in the controller . when I create a POST , I need the USER ID .

so I try this -

 $user = auth()->guard('api');
        dd($user);

but is returning NULL , the userr

aligajani commented 4 years ago

Try $id = $data->save()->id;

ibrainventures commented 4 years ago

try: $userId = auth()->user()->id;

stale[bot] commented 3 years ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.