jwt-auth icon indicating copy to clipboard operation
jwt-auth copied to clipboard

cant install on lumen 6

Open Rasoul-Karimi opened this issue 5 years ago • 4 comments

hi I get an error when installing on lumen 6

Your environment

Q A
Bug? no / yes
New Feature? no / yes
Framework Lumen
Framework version 6
Package version 0.5.12
PHP version 7.x.y

Problem 1 - Installation request for tymon/jwt-auth ^0.5.12 -> satisfiable by tymon/jwt-auth[0.5.12]. - Conclusion: remove illuminate/contracts v6.13.1 - Conclusion: don't install illuminate/contracts v6.13.1

Rasoul-Karimi avatar Feb 04 '20 11:02 Rasoul-Karimi

Try this:

composer require tymon/jwt-auth:1.0.0-rc.5.1

Support for Laravel 6 was added on 1.0.0-rc.5

pr1s10n3r avatar Feb 07 '20 19:02 pr1s10n3r

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.

stale[bot] avatar Dec 25 '20 20:12 stale[bot]

My difficulty is being in the installation in lumen 8 Some adaptation in the tutorial to make it work

I get the error: Target class [api] does not exist.

EwertonDutra avatar Feb 27 '21 11:02 EwertonDutra

My difficulty is being in the installation in lumen 8 Some adaptation in the tutorial to make it work

I get the error: Target class [api] does not exist.

there's a mistake in documentation , in lumen there's no middleware named api , the right middleware that registered in bootstrap/app.php is

$app->routeMiddleware([ 'auth' => App\Http\Middleware\Authenticate::class, ]);

wrong code in documentation

Route::group([

  here -->  'middleware' => 'api',
    'prefix' => 'auth'

], function ($router) {

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

});

change the middleware to 'auth' and move login route out of route group so yo can access it without token

the right code

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

Route::group([
    'middleware' => 'auth',
    'prefix' => 'api'
], function ($router) {
    Route::post('logout', 'AuthController@logout');
    Route::post('refresh', 'AuthController@refresh');
    Route::post('me', 'AuthController@me');
});

curl 127.0.0.1:8000/api/login --data "[email protected]&password=123"

{"access_token":"eyJ0e...","token_type":"bearer","expires_in":3600}

curl 127.0.0.1:8000/api/me -H "Authorization: Bearer eyJ0e..." -X POST

{"id":1,"name":"admin","email":"[email protected]","email_verified_at":null,"remember_token":null,"created_at":"2021-12-30T19:11:42.000000Z","updated_at":"2021-12-30T19:11:42.000000Z","permissions":""}

abdulbasetbasher avatar Dec 30 '21 23:12 abdulbasetbasher