Releases: camposgaston/Laravel-8-JWT-API
Articles API
#Added articles table
#Seeder for users & articles tables
#articles CRUD Routes added, only work sending Bearer Token from logged user.
All routes can be found here:
https://documenter.getpostman.com/view/11203636/TVYGbHQT
Users API Working
The login method is used to provide access to the user, and it is triggered when /api/auth/login API is called. It authenticates email and password entered by the user in an email and password field. In response, it generates an authorization token if it finds a user inside the database. Vice versa it displays an error if the user is not found in the database.
The register method is used to create a user when /api/auth/register route is called. First, user values such as name, email and password are validated through the validation process, and then the user is registered if the user credentials are valid. Then, it generates the JSON Web Token to provide valid access to the user.
The logout method is called when /api/auth/logout API is requested, and it clears the passed JWT access token.
The refresh method creates a new JSON Web Token in a shorter period, and It is considered a best practice to generate a new token for the secure user authentication system in Laravel 7. It invalidates the currently logged in user if the JWT token is not new.
The userProfile method renders the signed-in user’s data. It works when we place the auth token in the headers to authenticate the Auth request made through the /api/auth/user-profile API.
The createNewToken function creates the new JWT auth token after a specified period of time, we have defined token expiry and logged in user data in this function.
Start the laravel application with following command:
php artisan serve