Questions tagged [laravel-middleware]

HTTPl Middleware is a mechanism for filtering HTTP requests that are passing through your application. Middleware allows you to add additional layers around your business logic.

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. However, if the user is authenticated, the middleware will allow the request to proceed further into the application.

Of course, middleware can be written to perform a variety of tasks besides authentication. A CORS middleware might be responsible for adding the proper headers to all responses leaving your application. A logging middleware might log all incoming requests to your application.

There are several middleware included in the Laravel framework, including middleware for maintenance, authentication, CSRF protection, and more. All of these middleware are located in the app/Http/Middleware directory.

Reference

558 questions
0
votes
1 answer

Laravel Default Auth not redirecting to correct path

I'm having issues with getting the built-in Laravel Auth redirecting to the correct path when the user is not logged in. From the documentation it appears I can add the following to AuthController.php // redirect paths protected…
Daniel Benzie
  • 479
  • 1
  • 5
  • 27
0
votes
1 answer

How can I use laravel 5.1 middleware parameter for multiple auth and protected routes?

I'm new to laravel 5.1. How can I use middleware parameter to protect my admin routes from users ? something like this: Route::group(['middleware' => 'auth:admin'], function() /* Admin only Routes*/ { ////// }); I have a field "role" in my…
0
votes
2 answers

Laravel - Allow only the owner of the note to view it and edit it: Middleware or FormRequests?

Imagine a personal notes app. Users can add, view and edit their own notes, but not notes that belong to other users. The notes are accessed this way: app.dev/notes/{id} So naturally, if I own a note that has an ID of 140, but change the id to 160…
munich
  • 500
  • 1
  • 6
  • 16
0
votes
2 answers

Laravel 5.1: Handling missing fields in RESTful API

In my Laravel 5.1 application, I have a controller that serves as a RESTful API. Many methods of this controller have a following piece of code: foreach (['email', 'password', 'firstName', 'lastName'] as $parameter) { if…
Robo Robok
  • 21,132
  • 17
  • 68
  • 126
0
votes
1 answer

Allow CRUD only to Auth::user that owns the ressource

I currently work on a project where the User creates Models, that only he/she is allowed to see, edit or delete. The Create Part done by Eloquent Relationships, but for the other operations I would like to combine it with Route Model binding and not…
Florian Bauer
  • 626
  • 3
  • 12
0
votes
1 answer

Laravel 5 create middleware with oauth2 server check

I have implemented this oauth server http://bshaffer.github.io/oauth2-server-php-docs/ It has a Laravel implementation : http://bshaffer.github.io/oauth2-server-php-docs/cookbook/laravel/ This guide you and gives that code for routes :…
Jeremy Belolo
  • 4,319
  • 6
  • 44
  • 88
0
votes
0 answers

Create Users for logged in Admin users

I wanted to give option to create users for Admin without using Registration form. Do I need to change existing methods and forms ? How do I store password with encryption same as in default registration option. what is the best way to do it? …
Chanuka Asanka
  • 2,798
  • 3
  • 24
  • 36
0
votes
1 answer

Change password for logged in users

Basically I need change password form in edit profile view after users logged in. I already using password reset function for guest users. is there any interface to change password or method to override in laravel 5. Do I need to write some method…
Chanuka Asanka
  • 2,798
  • 3
  • 24
  • 36
0
votes
2 answers

middleware does not working laravel 5

I'm trying to use auth middleware within my controller at construct method with except argument and it does not working. I created my controller with artisan command and its contains methods like create, edit, show, etc. here is my construct: public…
Ravexina
  • 2,406
  • 2
  • 25
  • 41
0
votes
1 answer

Laravel 5 Middleware

Hi I am using Middleware of Laravel 5 and what I am doing is I have middleware which is being used in few controllers, and each of my controllers has it's own configs, which I need to pass my middleware, how can I do that?
Hayk Aghabekyan
  • 1,087
  • 10
  • 19
0
votes
2 answers

Laravel 5 - Assign Middleware to Controller Namespace

I need to do an ACL check for the user before allowing access to the admin panel of a Laravel 5 website. What is the best way to do this for an entire controller group in the namespace App\Http\Controllers\Admin\*? Ultimately, I'm looking for a "set…
Siphon
  • 1,041
  • 8
  • 17
-1
votes
3 answers

laravel Middleware has no redirect on route dash board

i am trying to make authentication of laravel with middleware but my middleware not working to redicrect to admin/dashboard page my code below have data in data base that roll_as is 1 and i trying to login as admin but when i give input of login…
-1
votes
2 answers

How to set "app.locale" by Session in every Request in Laravel?

I am developing a localization in Laravel 10. When I triggered to change the flag of Localization Then Error Show in Page. Can anyone tell Just where is the problem ? Error Message Call to undefined method…
-1
votes
2 answers

Can't use double middleware route in laravel

i have route api code like this Route::group(['middleware' => 'auth:api','web'], function(){ Route::get('user', 'Api\AuthController@user'); Route::get('kurir', 'Api\AuthController@kurir'); Route::get('droppoint',…
-1
votes
1 answer

Make multiple user types access the same Route using Laravel 9 middleware

I followed this site on how to create user types and restrict page access. Everything works as expected, but I wanted the admin to also have access to the users pages. The app has several hierarchical levels and I don't want to have to repeat the…
redystum
  • 352
  • 3
  • 10