Today i gonna discuss about auth Middleware that is used for authentication.
Link of Lesson#7 • Lesson#7 | Laravel Middleware - Condition ...
Link of Lesson#6 • Lesson#6 | Laravel Basic Routing | Laravel...
Link of Lesson#5 • Lesson#5 | Laravel Data Insert in Database
Link of Lesson#4 • Lesson#4 - Laravel MVC - Model and Migration
Link of Lesson#3 • Lesson#3 | Laravel MVC | what is Controller ?
Link of Lesson#2 • Lesson#2 | Laravel login and registration
Link of Lesson#1 • Lesson#1| Laravel setup and installation o...
Middleware(Auth)
----------------
Middleware provide a convenient mechanism for filtering HTTP requests entering your application.
example
--------
1)MiddleWare can check condition which i have discussed in last lesson.(Lesson#7)
2)Laravel includes a middleware that verifies the user of your application is authenticated. If the user is not authenticated, the middleware will redirect the user to the login screen.
In laravel, Auth is a built-in middleware that can be used for authentication.
This can be done in several ways. Now i am going to discuss about this in two ways.
First
-----
First i will discuss the route method "get" which has route url called "test". when the route executes, it
executes the "auth" middleware first. Then if the user is authenticated, i mean if the user is logged in,
then it will execute the "return view" statement. If the user is not logged in, then he will redirece to
the login page. in this case he can not access the route url "date_range".
Route::get('test', function() {
return view('date_range');
})- middleware('auth');
Second
-------
Route groups allow you to share route attributes, such as middleware, across a large number of routes without needing to define those attributes on each individual route.
To assign middleware to all routes within a group, you may use the middleware method before defining the group.
Route::middleware(['auth'])- group(function () {
Route::get('/date_range', [App\Http\Controllers\DateRangeController::class,'index']);
Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])- name('home');
});
Here you can write all the routes inside group and auth buuilt-in middleware is applicable to all routes
you have written inside the group.
Source :
https://laravel.com/docs/8.x/routing
You can find the description in :
laravel authentication middleware, laravel 7 middleware, laravel 8 middleware,
middleware laravel 8, middleware laravel in hindi, laravel middleware authentication,
laravel middleware auth role, laravel auth middleware,laravel middleware auth,
laravel middleware hindi, laravel middleware tutorial, group middleware in laravel,
laravel group middleware, laravel middleware tamil, laravel middleware bangla,
authentication middleware in bangla, what is middleware in laravel,middleware laravel 8,
laravel middleware tutorial,larvel builtin middleware, laravel route group
Информация по комментариям в разработке