2017-02-27 79 views
0

我使用Laravel 5.3與代客。Laravel 5.3重定向如果沒有登錄

web.php

Auth::routes(); 
Route::group(['middleware' => 'auth'], function() { 
    Route::get('/dashboard', '[email protected]'); 
}); 

Kernel.php

protected $routeMiddleware = [ 
    'auth' => \Illuminate\Auth\Middleware\Authenticate::class, 
    'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 
    'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, 
    'can' => \Illuminate\Auth\Middleware\Authorize::class, 
    'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 
    'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 
]; 

如果我打的/dashboard路線登錄,它拋出一個異常,而不是重定向我到/login頁。 exception

這是正確的行爲還是我錯過了什麼?我以爲它應該將你重定向到登錄頁面,不是嗎?

+0

我剛剛在您使用的模塊中修復了Laravel^5.3的兼容性問題: https://github.com/darkwinternight/laravel-error-handler/pull/6 – mash1t

回答

1

是的,它應該重定向。當不是api請求時,全新安裝將在未登錄時重定向。

它似乎不再捕獲錯誤,而是允許它一直顯示到頂部。

可能您對App\Exceptions\Handler.php代碼進行了更改,導致它跳過正確處理這些錯誤的過程。

+0

是的,這是因爲我正在使用[這](https://github.com/darkwinternight/laravel-error-handler)包需要你擴展它自己的處理程序。我在那裏爲主人發佈了一個問題。 – ProEvilz

+1

太棒了。很高興的答案讓你走上正軌 – Chris