/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @return mixed */ public function handle($request, Closure $next) { if (!$this->config->get('u2f.enable')) { return $next($request); } if (!$this->u2f->check()) { if (!\Auth::guest()) { if (U2fKey::where('user_id', '=', \Auth::user()->id)->count() === 0 && $this->config->get('u2f.byPassUserWithoutKey')) { return $next($request); } else { return redirect()->guest('u2f/auth'); } } else { throw new HttpException(401, 'You need to log in before an u2f authentication'); } } return $next($request); }
/** * @author LAHAXE Arnaud * * * @return mixed */ public function auth() { try { $key = $this->u2f->doAuthenticate(\Auth::user(), \Session::get('u2f.authenticationData'), json_decode(\Input::get('authentication'))); \Event::fire('u2f.authentication', ['u2fKey' => $key, 'user' => \Auth::user()]); \Session::forget('u2f.authenticationData'); return $this->redirectAfterSuccessAuth(); } catch (\Exception $e) { \Session::flash('error', $e->getMessage()); return \Redirect::route('u2f.auth.data'); } }