laravel-middleware

Cannot get TrustProxies middleware to work

前提是你 提交于 2019-12-11 15:43:50
问题 After pointed in the right direction here Laravel 5.4 relative instead of absolute 302 redirects I've been trying to get Laravel TrustProxies middleware to work, but seems to be ignoring X_FORWARDED_PROTO header. My scenario My app in Laravel (just upgraded from 5.4 to 5.5) is behind a load balancer, which translates all traffic from HTTPS to HTTP. My problem All redirects are going over HTTP instead of original protocol HTTPS. Attempted Solution Upgrade from Laravel 5.4 to 5.5 and take

Laravel 5 | Interface 'Illuminate\Contracts\Routing\Middleware' not found

我怕爱的太早我们不能终老 提交于 2019-12-10 22:38:32
问题 I use Laravel 5. I try, "use Illuminate\Contracts\Routing\Middleware;" to implement "Middleware" as, class Language implements Middleware { // Some Functions } I Get Error as, Interface 'Illuminate\Contracts\Routing\Middleware' not found Is actually that interface is Missing ? (OR) Mistake in defining ? (OR) Need to Create | Download ? Thank Q ! 回答1: The Illuminate\Contracts\Routing\Middleware contract has been deprecated in 5.2, remove it. And dont use it in class definition. Like this <?php

Using Auth::user in middleware

霸气de小男生 提交于 2019-12-10 14:04:26
问题 I'm trying to check if the URL entered is the same as the authenticated users slug in the database. So if a user goes to example.com/user/bob-smith and it is in fact Bob Smith logged in, the application will let Bob continue because his slug in the User table is bob-smith. I have the middleware registered but when I do public function handle($request, Closure $next) { if($id != Auth::user()->slug){ return 'This is not your page'; } else{ return $next($request); } } I get Class 'App\Http

How to log every response in laravel 5.2 framework

ⅰ亾dé卋堺 提交于 2019-12-07 07:25:25
问题 I was using below code for logging each and every request and response for my API but now it's not working for Laravel 5.2. I have tried to use https://laravel.com/docs/5.2/middleware#terminable-middleware but not succeed. use Closure; use Illuminate\Contracts\Routing\TerminableMiddleware; use Illuminate\Support\Facades\Log; class LogAfterRequest implements TerminableMiddleware { public function handle($request, Closure $next) { return $next($request); } public function terminate($request,

how to guard a controller through multiple of user?

瘦欲@ 提交于 2019-12-06 17:01:00
问题 It is project requirement. where i have multiple logins but some user can not access few module. like super admin and analyst can access all module but developer can only use own controller. so in this case , how can i guard a controller with multiple logins. also note that i have separate login page and table into Database. for Example phonebookController can be access by super admin and analyst but not by developers. so please tell me how can i implement this? i use this for :: if( Auth:

Intercept Laravel Routing

孤者浪人 提交于 2019-12-06 11:14:11
问题 I am busy building a Restful API in Laravel 5.1 where the API version is passed through the header. This way I can version the features rather than copy and pasting a whole route group and increment the version number. The problem I'm having is that I would like to have versioned methods, IE: public function store_v1 (){ } I have added a middleware on my routes where I capture the version from the header, but now need to modify the request to choose the correct method from the controller. app

Laravel Middleware Auth for API

萝らか妹 提交于 2019-12-06 06:16:00
I am currently developing and application that has an API which I want to be accessible through middleware that will check if the user is authenticated using either Laravel's default Auth middleware and Tymone's JWT.Auth token based middleware so requests can be authenticated either of the ways. I can work out how to have one or the other but not both, how could I do this? I'm thinking I need to create a custom middleware that uses these existing middlewares? I am using Laravel 5.1 Thanks Turns out I did need to make my own middleware which was easier than I thought: <?php namespace App\Http

Temporarily disable / bypass Middleware

大憨熊 提交于 2019-12-05 08:02:21
In my Application I implemented a OAuth2-Server ( oauth2-server-laravel ) in combination with a custom Authentication Package ( Sentinel by Cartalyst ). In my routes.php: Route::group(['before' => 'oauth'], function() { // ... some routes here } So the request must provide an authorization header or the application quits with an OAuthException. Now I want to unittest my controllers. So I have to seed my database with a OAuth session and access token for every test. Then overwrite the call() -method of TestCase and set the HTTP-Authorization Header with the Bearer Token. Is there a way to

how to guard a controller through multiple of user?

限于喜欢 提交于 2019-12-04 21:03:26
It is project requirement. where i have multiple logins but some user can not access few module. like super admin and analyst can access all module but developer can only use own controller. so in this case , how can i guard a controller with multiple logins. also note that i have separate login page and table into Database. for Example phonebookController can be access by super admin and analyst but not by developers. so please tell me how can i implement this? i use this for :: if( Auth::guard('superAdmin')->check() ) { $author =Auth::guard('superAdmin')->User()->id ; } else if( Auth::guard(

Intercept Laravel Routing

大兔子大兔子 提交于 2019-12-04 17:20:20
I am busy building a Restful API in Laravel 5.1 where the API version is passed through the header. This way I can version the features rather than copy and pasting a whole route group and increment the version number. The problem I'm having is that I would like to have versioned methods, IE: public function store_v1 (){ } I have added a middleware on my routes where I capture the version from the header, but now need to modify the request to choose the correct method from the controller. app/Http/routes.php Route::group(['middleware' => ['apiversion']], function() { Route::post('demo',