TranslateOAuthException   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 22
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 12 2
1
<?php
2
3
namespace App\Http\Middleware;
4
5
use Closure;
6
7
class TranslateOAuthException
8
{
9
    /**
10
     * Handle an incoming request.
11
     *
12
     * @param \Illuminate\Http\Request $request
13
     * @param \Closure                 $next
14
     *
15
     * @return mixed
16
     */
17
    public function handle($request, Closure $next)
18
    {
19
        //Convert oauth 400 response to 401 without any payload
20
        //It's required due to security reasons - we got two levels of "authentication" - the first is to check if user
21
        //exists in IdentifyTenantByUsername middleware - so we need IDENTICAL(!) responses here and there
22
        $response = $next($request);
23
24
        if ($response->status() === 400) {
25
            return response('', 401);
26
        }
27
28
        return $response;
29
    }
30
}
31