This project has been archived. If you're curious, check out one of my latest courses:
If you work with JavaScript, check out the fetch use cases and JavaScript projects.
Thank you! — Jad Joubran
In order to protect a certain route with the JWT Auth Guard, you need to specify auth:api
as a middleware. Just like the example already present in your routes/api.php
.
You can create a token by attempting to login with user's credentials.
$token = Auth::attempt(['email' => '[email protected]', 'password' => 'secret']);
You can check whether the user is authenticated
if (Auth::check()) {
//
}
or not
if (Auth::guest()) {
//
}
You can get the authenticated user
$user = Auth::user();
Explore the full documentation.