我的laravel版本是5.0.35,我的問題是當我註銷時,它會重定向回主頁。Laravel 5.0註銷重定向回到主頁
經過數小時的自我研究和谷歌搜索,我經歷了許多決議,但沒有工作。 例如:$ this-> middleware('guest',['except'=> ['logout','getLogout']]);
由於某種原因,訪客中間件正在將請求重定向回主頁,不知道爲什麼即使添加註銷方法時也會免除註銷方法。 任何人都請幫我解決這個問題。
我AuthController現在
<?php namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Contracts\Auth\Registrar;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class AuthController extends Controller {
/*
|--------------------------------------------------------------------------
| Registration & Login Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users, as well as the
| authentication of existing users. By default, this controller uses
| a simple trait to add these behaviors. Why don't you explore it?
|
*/
use AuthenticatesAndRegistersUsers;
/**
* Create a new authentication controller instance.
*
* @param \Illuminate\Contracts\Auth\Guard $auth
* @param \Illuminate\Contracts\Auth\Registrar $registrar
* @return void
*/
public function __construct(Guard $auth, Registrar $registrar)
{
$this->auth = $auth;
$this->registrar = $registrar;
$this->middleware('guest', ['except' => 'logout']);
}
public function logout(Request $request)
{
$this->guard()->logout();
$request->session()->invalidate();
return redirect('/'); //****** Change to your desired link.
}
}
我有一個希望的項目升級到5.1.0來解決問題,但還是沒有用。 任何人都請幫忙。
你怎麼想呢? – shigg