We noticed you're using an ad blocker

Our website is made possible by displaying online advertisements to our visitors. Please consider supporting us by disabling your ad blocker.

Laravel 8 authentication tutorial

world cup 2022


Get update standing EPL, UEFA, LaLiga and more

Get Now

We need an authentication system for keeping our application private. Making authentication in Laravel is quite easy. It has a built-in solution for authentication and various facility to customize it according to our requirements. If you are new in Laravel 8 then in this post I'll show you the step by step process for making authentication system in Laravel 8. Let's follow the step by step process for making authentication system in Laravel 8.


Steps for Laravel 8 authentication

  1. Create a Laravel 8 project
  2. Install the Laravel UI package
  3. Generate auth scaffolding
  4. Install NPM dependencies
  5. Test the authentication system
  6. Restrict the required routes
  7. Change the necessary configuration


Create a Laravel 8 project

First, we have to create a Laravel 8 project. If you already installed Laravel 8 then skip this step and look forward.

composer create-project laravel/laravel laravel8 8.0

Here laravel8 is our project name and 8.0 means we are going to install laravel 8.0 version.


Install the Laravel UI package

Install the Laravel UI official package for making auth scaffolding in Laravel 8. Run the composer command to install Laravel UI package.

composer require laravel/ui


Generate auth scaffolding

After installation of Laravel UI package. We are now able to scaffold our auth with Bootstrap, Vue, React etc. If we want to generate scaffold with Vue then we have to run the command like below.

php artisan ui vue --auth


Install NPM dependencies

In this step, we have to install all our NPM dependencies. To install NPM dependencies run the command given below.

npm install

to compile assets run the command npm run dev

npm run dev


Test the authentication system

Now our Laravel 8 auth system is ready to use. To check authentication is successfully installed or not. Please browse the links given below.

To login check


To registration check



Disable Registration System

If you want to disable the new user registration system. Then go to the web.php route file and change the auth route.

Auth::routes(['register' => false]);


Route restriction

After successfully installation of Laravel 8 auth system. We can protect our routes for unauthenticated users by using auth middleware in our routes or controller.

Route::get('dashboard', 'App\Http\Controllers\UserController@dashboard')->middleware('auth');

or we can protect by our controller in the constructor function.


class UserController extends Controller
	public function __construct()

	public function dashboard(){



To check user authenticated or not in the view or anywhere in the controller we can use auth()->check()

  // If the user only authenticated

To get current authenticated user data.

$user = auth()->user();


Change the necessary configuration


Redirect path customization

When a user successfully login the default auth system redirects the user to /home path. If we want to change the path we have to change public const HOME = '/home'; from the RouteServiceProvider

public const HOME = '/dashboard';

Username customization

Laravel auth system by default check user email. If we want to check username instead of checking email then we have to add this method into the login controller.

// app/Http/Controllers/Auth/LoginController.php

public function username()
    return 'username';


Hope this step by step tutorial for Laravel 8 authentication will help you to make your own Laravel 8 authentication system. If this tutorial post helps you then please share this tutorial with others.


Share on

Related Post - Latest Post

Tinkerpad - A minimal Laravel code editor

What's new in Laravel 9

Make laravel site super fast by page-cache!

Laravel maintenance mode bypass by Secret Route!

Laravel database backup automatically - cPanel shared hosting, VPS

Laravel Datatables - Ajax, Column, Buttons, Customization