Laravel - Authentication

Laravel - Authentication

Authentication is the process of identifying user credentials. In web applications, authentication is managed by sessions that accept input parameters such as email or username and password to identify the user. If these parameters match, the user is considered authenticated.


Laravel uses the following command to create forms and associated controllers to perform authentication −

php artisan make:auth

This command helps to successfully create authentication forests, as shown in the following screenshot:


The controller that is used for the authentication process is the HomeController .

<? php

namespace App \Http\Controllers ; 

use App \Http\Requests ; use Illuminate \Http\Request ; 

class HomeController extends Controller { /**   
      * Create a new controller instance.
      * @return void
   public function __construct () { 
      $this -> middleware ( 'auth' ); }  
      * Show the application dashboard.
      * @return \Illuminate\Http\Response
   public function index () { return view ( 'home' ); } }  

As a result, the generated scaffold application creates a login page and a registration page to perform authentication. They are as shown below −

Manual User Authentication

Laravel uses the Auth facade to help manually authenticate users. It includes a method of trying to verify your email and password.

Consider the following lines of code for LoginController which includes all functions for authentication −