Home> PHP Framework> Laravel> body text

Laravel - Authentication

WBOY
Release: 2024-08-27 13:13:22
Original
258 people have browsed it

Laravel - Authentication is the process of identifying the user credentials. In web applications, authentication is managed by sessions which take the input parameters such as email or username and password, for user identification. If these parameters match, the user is said to be authenticated.

Command

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

php artisan make:auth
Copy after login

This command helps in creating authentication scaffolding successfully, as shown in the following screenshot −

Laravel - Authentication

Controller

The controller which is used for the authentication process isHomeController.

middleware('auth'); } /** * Show the application dashboard. * * @return IlluminateHttpResponse */ public function index() { return view('home'); } }
Copy after login

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

Login

Login Page

Registration

Laravel - Authentication

Manually Authenticating Users

Laravel uses theAuthfaçade which helps in manually authenticating the users. It includes theattemptmethod to verify their email and password.

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

$email, 'password' => $password])) { // Laravel - Authentication passed... return redirect()->intended('dashboard'); } } }
Copy after login

The above is the detailed content of Laravel - Authentication. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!