Getting authentication right is not a straightforward task. Thankfully, Laravel has released an official authentication package called Laravel Fortify that took care of everything about authentication for us.
In summary, Fortify mainly consisted of 7 components:
- Login
- Logout
- Password confirmation
- Registration
- Password reset
- Email Verification
- 2-Factor Authentication
Laravel Fortify has preloaded a lot of API endpoints for us. Below is a brief overview on the endpoints that are available to us.
Login
GET /login
Returns the auth.login
view.
POST /login
Request body:
- email(string) — configurable in
config/fortify.php
- password(string)
- remember(boolean)
Non XHR API:
On success, redirect to home
route defined in fortify config.
On failure, redirect to login screen with errors.
XHR API:
On success, returns 200 HTTP response.