Example #1
0
 /**
  * Fired when the form is posting.
  *
  * @param UserSecurity $security
  */
 public function onPosting(UserSecurity $security)
 {
     $response = $security->attempt();
     if ($response instanceof Response) {
         $this->setFormResponse($response);
         $this->setSave(false);
     }
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure                 $next
  * @return mixed
  */
 public function handle(Request $request, Closure $next)
 {
     $response = $this->security->check($this->guard->user());
     if ($response instanceof Response) {
         return $response;
     }
     return $next($request);
 }
 /**
  * Handle the form.
  *
  * @param LoginFormBuilder  $builder
  * @param UserAuthenticator $authenticator
  * @param UserSecurity      $security
  * @param Redirector        $redirect
  */
 public function handle(LoginFormBuilder $builder, UserAuthenticator $authenticator, UserSecurity $security, Redirector $redirect)
 {
     if (!($user = $builder->getUser())) {
         return;
     }
     $response = $security->check($user);
     if ($response instanceof Response) {
         $authenticator->logout($user);
         $builder->setFormResponse($response);
         return;
     }
     $authenticator->login($user, $builder->getFormValue('remember_me'));
     $builder->setFormResponse($redirect->intended($builder->getFormOption('redirect', '/')));
 }
Example #4
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure                 $next
  * @return mixed
  */
 public function handle(Request $request, Closure $next)
 {
     $response = $this->security->check($this->guard->user());
     if ($response instanceof Response) {
         return $response;
     }
     if ($this->guard->guest()) {
         if ($request->ajax()) {
             return $this->response->make('Unauthorized.', 401);
         } else {
             if ($request->segment(1) === 'admin') {
                 return $this->redirect->guest('admin/login');
             } else {
                 return $this->redirect->guest('login');
             }
         }
     }
     return $next($request);
 }