Esempio n. 1
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if ($this->auth->guard($guard)->guest()) {
         return response('Unauthorized.', 401);
     }
     return $next($request);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if ($this->auth->guard($guard)->guest()) {
         return response(['success' => false, 'message' => 'Unauthorized.']);
     }
     return $next($request);
 }
Esempio n. 3
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if ($this->auth->guard($guard)->guest()) {
         return response()->json(['success' => false, 'errors' => ['Your token is invalid']], 400);
     }
     return $next($request);
 }
Esempio n. 4
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if ($this->auth->guard($guard)->guest()) {
         return redirect('login');
     }
     return $next($request);
 }
Esempio n. 5
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if ($this->auth->guard($guard)->guest()) {
         throw new UnauthorizedHttpException('Authorization');
     }
     return $next($request);
 }
Esempio n. 6
0
 /**
  * Determine if the user is logged in to any of the given guards.
  *
  * @param  array  $guards
  * @return void
  *
  * @throws \Illuminate\Auth\AuthenticationException
  */
 protected function authenticate(array $guards)
 {
     if (empty($guards)) {
         return $this->auth->authenticate();
     }
     foreach ($guards as $guard) {
         if ($this->auth->guard($guard)->check()) {
             return $this->auth->shouldUse($guard);
         }
     }
     throw new AuthenticationException('Unauthenticated.', $guards);
 }
Esempio n. 7
0
 /**
  * Determine if the user is logged in to any of the given guards.
  *
  * @param  array  $guards
  * @return void
  *
  * @throws \Illuminate\Auth\AuthenticationException
  */
 protected function authenticate(array $guards)
 {
     if (count($guards) <= 1) {
         $this->auth->guard(array_first($guards))->authenticate();
         return $this->auth->shouldUse($guard);
     }
     foreach ($guards as $guard) {
         if ($this->auth->guard($guard)->check()) {
             return $this->auth->shouldUse($guard);
         }
     }
     throw new AuthenticationException();
 }
Esempio n. 8
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if ($guard === '*') {
         $guard = null;
         $defaultGuard = $this->auth->guard();
         if ($defaultGuard instanceof UniversalGuard) {
             $guard = $defaultGuard->universalUserLogin($this->auth);
         }
     }
     if ($guard === false || $this->auth->guard($guard)->guest()) {
         return response('Unauthorized.', 401);
     }
     if ($guard !== null) {
         $this->auth->setDefaultDriver($guard);
     }
     return $next($request);
 }
 public function logout(Auth $auth)
 {
     $auth->guard($this->guard)->logout();
     return redirect('/user');
 }
 /**
  * Create a new filter instance.
  *
  * @param  AuthFactory $auth
  */
 public function __construct(AuthFactory $auth)
 {
     $this->guard = $auth->guard('backend');
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     return $this->auth->guard($guard)->basic() ?: $next($request);
 }
 public function logout(Auth $auth)
 {
     $auth->guard($this->getAttribute('guard'))->logout();
     return redirect('/' . $this->getAttribute('guard'));
 }
 public function logout(Auth $auth)
 {
     $auth->guard($this->guard)->logout();
     return redirect($this->redirectAfterLogout);
 }
Esempio n. 14
0
 /**
  * @inheritdoc
  */
 public function universalUserLogin(AuthFactory $auth)
 {
     try {
         $guard = Authorizer::getResourceOwnerType();
     } catch (\Exception $e) {
         $guard = null;
     }
     if ($guard === null) {
         return false;
     }
     $user = $auth->guard($guard)->user();
     if ($user === null) {
         $guard = false;
     }
     return $guard;
 }