In this opst I will help you to implement user authentication in your Laravel 7.x project with example.
In this opst, we’ll see how to add user authentication in Laravel 7.x with login, registration, logout and password reset example.
Install user authentication UI package
Authentication UI laravel/ui package provides a quick way to Scaffolding all of the routes and views you need for authentication using a few simple commands. Login into your SSH terminal and run following commands:
We should run the previous php artisan ui vue –auth command on new Laravel 7.x projects for generating a complete layout with user registration, login, logout, and password reset views and routes for user authentication. This will also generate a HomeController for handling the requests after user login.
The php artisan php artisan ui vue –auth command will create the necessary views for user authentication in your project resources/views/auth and resources/views/layouts folder. In layouts folder created app.blade.php layout blade for your application which makes use of the Bootstrap CSS framework.
The php artisan php artisan ui vue –auth command will create the necessary authentication controllers, users can login, logout, register, password reset and verify authenticate in app\Http\Controllers\HomeController.php and app\Http\Controllers\Auth folder.
Now, we need to add the authentication routes in our Laravel 7.x project in file routes\web.php. Open web.php you should find the following code:
The Auth::routes() method includes the routes for login, registration, logout, and password reset. Auth::routes() method along with the home route was added when added the auth scaffolding in the previous section.
Now we can access via web browser address bar to Login, register, reset etc, you should see the following interface:
We can see the views have no styling. So we need to set Twitter Bootstrap 3.x CSS or own CSS style.
Change authentication home url
We can change authentication url home to myaccount or anything else from app\Providers\RouteServiceProvider.php file. Currently after user login or refister redirect to authentication area with home url.
Thank you for carefully read my article If you have any query please Leave your query on following comment section or contact with us. Please LIKE and SHARE
One reply on “Laravel 7.x user authentication Login – Register – Password Reset”
Wonderful web site. A lot of helpful information here.
I am sending it to some pals ans additionally sharing in delicious.
And naturally, thanks to your sweat!