tymondesigns / jwt-auth

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

How to get user from JWTAuth when my table is not default users table #1574

Open mataheri opened 6 years ago

mataheri commented 6 years ago

Subject of the issue

I'm going to use JWTAuth to create token from a model. So I used this method:

$token = JWTAuth::fromUser($user);

In my api routes I have:

Route::post('login', 'AuthController@login');

Route::group([

    'middleware' => 'jwt.auth',
    'prefix' => 'auth'

], function ($router) {

    Route::post('logout', 'AuthController@logout');
    Route::post('refresh', 'AuthController@refresh');
    Route::get('me', 'AuthController@me');
});

Now I should have access to get user from JWTAuth. Then I use:

$user = JWTAuth::parseToken()->authenticate();

But it returns false.

Your environment

Q A
Bug? yes
New Feature? no
Framework Laravel
Framework version 5.5
Package version dev-develop
PHP version 7.2
muhaimincs commented 5 years ago

did it return false or 401? I have similar situation

https://stackoverflow.com/questions/53893570/laravel-jwt-auth-middleware-custom-user-table-always-return-401

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.