1
我在我的Laravel 5.2应用程序中使用认证。一切都好,但注销不起作用。任何人都可以向我解释,为什么它发生?Laravel 5.2不能注销
routes.php文件
Route::group([
'middleware' => ['web']
], function() {
Route::get('auth/login', 'Auth\[email protected]');
Route::post('auth/login', 'Auth\[email protected]');
Route::get('auth/logout', 'Auth\[email protected]');
...
});
Controller.php这样
class AuthController extends Controller
{
use AuthenticatesAndRegistersUsers, ThrottlesLogins;
public function __construct()
{
$this->middleware('guest', ['except' => 'logout', 'getLogout']);
}
public function logout()
{
/* This place not trigger */
echo 'Logout';
exit;
Auth::guard($this->getGuard())->logout();
return redirect(property_exists($this, 'redirectAfterLogout') ? $this->redirectAfterLogout : '/');
}
...
}
你当然对,谢谢。但是另外,这行必须是'$ this->中间件('guest',['除'=> ['logout','getLogout']]);'。 – Evgeniy
然后你可以尝试我的答案的第二个选项。希望这是工作.. –