Laravel 5 忽略身份验证特定路由

Laravel 5 ignore Authentication specific route

我是 laravel 5 的新人。我有一个仪表板页面和一个登录页面。每当我去 localhost:8080/dashboard 它总是将我重定向到 localhost:8080/auth/login

我想显示我的仪表板 localhost:8080/dashboard,无需先登录即可查看。这是我在 VerifyCsfrToken

中的代码
namespace App\Http\Middleware;

use Closure;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;

class VerifyCsrfToken extends BaseVerifier {

    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */


    protected $except_urls = [
        'dashboard/dashboard',
    ];

    public function handle($request, Closure $next)
    {
        $regex = '#' . implode('|', $this->except_urls) . '#';

        if ($this->isReading($request) || $this->tokensMatch($request) || preg_match($regex, $request->path()))
        {
            return $this->addCookieToResponse($request, $next($request));
        }

        throw new TokenMismatchException;

        return parent::handle($request, $next);
    }

}

routes.php

Route::get('dashboard', 'ReservationController@index');

 Route::controllers([
'auth' => 'Auth\AuthController',
'password' => 'Auth\PasswordController',
 ]);

控制器:

use App\reservations;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Console\Scheduling\Schedule;
use Carbon\Carbon;
use Request;

class ReservationController extends Controller {

/*
|--------------------------------------------------------------------------
| Welcome Controller
|--------------------------------------------------------------------------
|
| This controller renders the "marketing page" for the application and
| is configured to only allow guests. Like most of the other sample
| controllers, you are free to modify or remove it as you desire.
|
*/

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

/**
 * Show the application welcome screen to the user.
 *
 * @return Response
 */

public function schedule()
{
    $schedules = schedules::all();


    return view('calendar.schedule',compact('schedules'));
}
public function index()
{
return view('dashboard.dashboard');
}
public function create()
{

    return view('reserve.reserve');
}
public function update()
{
    return view('calendar.update');
}
public function login()
{
    return view('login');
}

public function store(Requests\CreateReservationRequest $request)
{

    $input = Request::all();
    $reservation = new reservations(['user_id'       => '13100024',
                                    'status_id'     => '1',
                                    'room_id'       => $input['room'],
                                    'purpose'       => $input['purpose'],
                                    'start_time'    => $input['date']."        ".$input['hour1'].":".$input['minute1'].":00",
                                    'end_time'      => $input['date']." ".$input['hour2'].":".$input['minute2'].":00",
                                    'add_date'      => Carbon::now()
                                    ]);
    $reservation->save();

    return "success";
   // return redirect('schedule');

   }

这是导致问题的原因:

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

它限制登录用户访问该页面。只需将其从您的控制器中删除,用户无论是否登录都可以访问该页面。

public function __construct()
{
    $this->middleware('auth', ['except' => ['Whatever You want to Bypass']]);
}