コード例 #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);
     }
 }
コード例 #2
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;
     }
     return $next($request);
 }
コード例 #3
0
 /**
  * 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', '/')));
 }
コード例 #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);
 }