Вход Регистрация
Файл: vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php
Строк: 95
<?php

namespace IlluminateAuthMiddleware;

use 
Closure;
use 
IlluminateAuthAuthenticationException;
use 
IlluminateContractsAuthFactory as Auth;
use 
IlluminateContractsAuthMiddlewareAuthenticatesRequests;

class 
Authenticate implements AuthenticatesRequests
{
    
/**
     * The authentication factory instance.
     *
     * @var IlluminateContractsAuthFactory
     */
    
protected $auth;

    
/**
     * Create a new middleware instance.
     *
     * @param  IlluminateContractsAuthFactory  $auth
     * @return void
     */
    
public function __construct(Auth $auth)
    {
        
$this->auth $auth;
    }

    
/**
     * Handle an incoming request.
     *
     * @param  IlluminateHttpRequest  $request
     * @param  Closure  $next
     * @param  string[]  ...$guards
     * @return mixed
     *
     * @throws IlluminateAuthAuthenticationException
     */
    
public function handle($requestClosure $next, ...$guards)
    {
        
$this->authenticate($request$guards);

        return 
$next($request);
    }

    
/**
     * Determine if the user is logged in to any of the given guards.
     *
     * @param  IlluminateHttpRequest  $request
     * @param  array  $guards
     * @return void
     *
     * @throws IlluminateAuthAuthenticationException
     */
    
protected function authenticate($request, array $guards)
    {
        if (empty(
$guards)) {
            
$guards = [null];
        }

        foreach (
$guards as $guard) {
            if (
$this->auth->guard($guard)->check()) {
                return 
$this->auth->shouldUse($guard);
            }
        }

        
$this->unauthenticated($request$guards);
    }

    
/**
     * Handle an unauthenticated user.
     *
     * @param  IlluminateHttpRequest  $request
     * @param  array  $guards
     * @return void
     *
     * @throws IlluminateAuthAuthenticationException
     */
    
protected function unauthenticated($request, array $guards)
    {
        throw new 
AuthenticationException(
            
'Unauthenticated.'$guards$this->redirectTo($request)
        );
    }

    
/**
     * Get the path the user should be redirected to when they are not authenticated.
     *
     * @param  IlluminateHttpRequest  $request
     * @return string|null
     */
    
protected function redirectTo($request)
    {
        
//
    
}
}
Онлайн: 0
Реклама