예제 #1
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $as = $request->input('_as');
     if ($this->authorize() && !is_null($as)) {
         $this->auth->loginUsingId($as);
         return $this->response->redirectTo($request->url());
     }
     return $next($request);
 }
예제 #2
0
파일: Can.php 프로젝트: quetzyg/foundation
 /**
  * Response on authorized request.
  *
  * @param  \Illuminate\Http\Request  $request
  *
  * @return mixed
  */
 protected function responseOnUnauthorized($request)
 {
     if ($request->ajax()) {
         return $this->response->make('Unauthorized', 401);
     }
     $type = $this->auth->guest() ? 'guest' : 'user';
     $url = $this->config->get("orchestra/foundation::routes.{$type}");
     return $this->response->redirectTo($this->foundation->handles($url));
 }
예제 #3
0
 /**
  * Get all possible user roles.
  *
  * @return array
  */
 protected function getUserRoles()
 {
     if (!is_null($this->userRoles)) {
         return $this->userRoles;
     } elseif (!$this->auth->guest()) {
         return $this->auth->roles();
     }
     return $this->roles->has('guest') ? ['guest'] : [];
 }
예제 #4
0
 /**
  * Check whether the menu should be displayed.
  *
  * @param  \Orchestra\Contracts\Auth\Guard  $auth
  *
  * @return bool
  */
 public function authorize(Guard $auth)
 {
     return !$auth->guest();
 }
예제 #5
0
 /**
  * Get user.
  *
  * @return \Orchestra\Model\User|null
  */
 protected function getUser()
 {
     return $this->auth->getUser();
 }