tymondesigns / jwt-auth

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

How to use both jwt.auth and auth middleware #1101

Open tanshiqi opened 7 years ago

tanshiqi commented 7 years ago

In my scene, I want user authentication from jwt token, if not valid then redirect to login page. How to do this? It doesn't work: Route::group([ 'middleware' => ['jwt.auth', 'auth'] ], function () { ... });

kofi1995 commented 7 years ago

If you follow the tutorial for the new JWT guard, you will understand you don't need to do this. The application looks at the header of the request and responds with the appropriate resource. If it is a json request, it responds with a token, else it redirects you to the login page.