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 5.2 or 5.3: How to Properly Implement a check to see if a session is Logged in already

I'm working on an application using Laravel 5.2.45, that interacts with an ionic front-end and with the server-side being tested using Postman. I'm a little stuck as to how to properly implement a check to see if the user's session is already active…
Andre F.
  • 1,123
  • 1
  • 10
  • 27
0
votes
1 answer

Laravel cache permission issue

I have a back-end server which is written using Laravel. Recently I started getting the following error (I show the full traceback): #0 /var/app/current/bootstrap/cache/compiled.php(7547):…
Dmitry Torba
  • 3,004
  • 1
  • 14
  • 24
0
votes
1 answer

Permissions in Laravel - ACL vs Middleware

I'm having a bit of trouble understanding the proper times to use ACL or middleware in Laravel. I do understand the examples on their site and Laracasts, but they're rather simple examples. This isn't anymore complicated by any means, but I didn't…
kenshin9
  • 2,215
  • 4
  • 23
  • 38
0
votes
0 answers

Laravel bug middleware

I put dd($next) for debug in my middleware like this (VerifyCsrfToken.php): public function handle($request, Closure $next) { dd($next); // Add this: if($request->method() == 'POST') { return $next($request); } if…
Marc Garcia
  • 1,388
  • 1
  • 9
  • 21
0
votes
1 answer

Laravel 5 - calling $request->path() in middleware causing Laravel to ignore changes made to the request URI?

Using Laravel 5.2, and using a middleware, I need to remove a certain part from the URI of the request before it gets dispatched. More specifically, in a url like "http://somewebsite.com/en/company/about", I want to remove the "/en/" part from…
pazof
  • 944
  • 1
  • 12
  • 26
0
votes
1 answer

Laravel - too many redirects issue

I'm on a project, the website have two types of users Admin and User. I made an middleware for the admin, the middleware is working correctly but when I try to login an issue showed up: too many redirects my routes:
Poula Adel
  • 609
  • 1
  • 10
  • 33
0
votes
1 answer

Laravel5: Conditional Routing (to make /usernickname pages)

In laravel 5 I want to route www.example.com/username response to a user profile page if user exists, just like twitter,facebook.. Sure I have pages like /blabla, but I don't allow users to have 'blabla' for username. In this case I tried lots of…
iedmrc
  • 742
  • 2
  • 8
  • 21
0
votes
1 answer

Can I create authentication without middleware?

I'm newbie at Laravel development. I'm really confuse between middleware and authentication . Can I create authentication system without using middleware in Laravel 5.2 ?
0
votes
3 answers

TokenMismatchException in VerifyCsrfToken.php line 67 - How to disable middleware and set that to be default

I'm studying Laravel through videos. I made a view with only a textbox and a submit button. After I clicked submit button, I have TokenMismatchException in VerifyCsrfToken.php line 67 error. TokenMismatchException in VerifyCsrfToken.php line…
Truong Van Hoc
  • 87
  • 3
  • 12
0
votes
3 answers

How to get the current logged in user in laravel middleware?

I'm trying to get the currently logged in user from my custom middleware like this: $user_id = Auth::user()->getKey(); but i get this error: Trying to get property of non-object any idea?
Mohammad AL-Raoosh
  • 721
  • 1
  • 12
  • 32
0
votes
1 answer

Laravel Middleware Cache not working properly

I'm trying to create middleware which will check status of specified server and put this status to the Cache, but the cache is not working in middleware properly, given cache value is always null when I'm trying to check the key existence…
Narkon
  • 398
  • 2
  • 17
0
votes
1 answer

Error on custom middleware checking the value returned on a Model custom Function Laravel 5.1

I have an account email confirmation for my Laravel app, then I want to check when the user tries to log in, if the user has activated his account. I found this:…
elotgamu
  • 43
  • 10
0
votes
1 answer

Token Mismatch Exception in laravel and changing of token for one page and not showing user login info on header

I have been working in laravel for more than 7 months now.Recently I uploaded my project on cpanel and saw that for one page the user login info is not shown and it seems like user is not logged in.Also when trying to add something to cart through…
Ash Asley
  • 23
  • 2
  • 5
0
votes
1 answer

Laravel 5.2: Session store not set on request. Error for Blade Templates with old()

I am testing with PHPUnit 4.0, Laravel 5.2, PHP 5.5.9, and keep getting the error ERROR: exception 'RuntimeException' with message 'Session store not set on request.' in /var/www/html/vendor/laravel/framework/src/Illuminate/Http/Request.php:85 To…
Nabsta
  • 101
  • 3
  • 12
0
votes
1 answer

Laravel 5.2 Does not show errors in register

I add my routes in web middleware. When I post null value in register, it does not show me validation errors. But when I remove web middleware from my route it works correctly. Route::group(['middleware' => ['web']], function () { …
paranoid
  • 6,799
  • 19
  • 49
  • 86