| Conditions | 6 |
| Paths | 5 |
| Total Lines | 24 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php namespace Lahaxearnaud\U2f\Http\Middleware; |
||
| 45 | public function handle($request, Closure $next) |
||
| 46 | { |
||
| 47 | if(!$this->config->get('u2f.enable')) { |
||
| 48 | return $next($request); |
||
| 49 | } |
||
| 50 | |||
| 51 | if (!$this->u2f->check()) { |
||
| 52 | if(!Auth::guest()){ |
||
| 53 | if( |
||
| 54 | U2fKey::where('user_id', '=', Auth::user()->getAuthIdentifier())->count() === 0 |
||
| 55 | && $this->config->get('u2f.byPassUserWithoutKey') |
||
| 56 | ) { |
||
| 57 | return $next($request); |
||
| 58 | } else { |
||
| 59 | return redirect()->guest('u2f/auth'); |
||
| 60 | } |
||
| 61 | |||
| 62 | } else { |
||
| 63 | throw new HttpException(401, 'You need to log in before an u2f authentication'); |
||
| 64 | } |
||
| 65 | } |
||
| 66 | |||
| 67 | return $next($request); |
||
| 68 | } |
||
| 69 | } |
||
| 70 |