Exemplo n.º 1
0
 /**
  * @author LAHAXE Arnaud
  *
  *
  * @return mixed
  */
 public function authData()
 {
     if ($this->u2f->check()) {
         return $this->redirectAfterSuccessAuth();
     }
     $req = $this->u2f->getAuthenticateData(\Auth::user());
     \Event::fire('u2f.authentication.data', ['user' => \Auth::user()]);
     \Session::set('u2f.authenticationData', $req);
     return view($this->config->get('u2f.authenticate.view'))->with('authenticationData', $req);
 }
Exemplo n.º 2
0
 /**
  * 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);
 }