亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

解決Laravel5.2 Auth認(rèn)證退出失效的問題

 更新時(shí)間:2019年10月14日 11:04:19   作者:野蠻秘籍  
今天在做登陸認(rèn)證時(shí)遇到了個(gè)問題,以為是我的解決方法,希望對大家有所幫助吧

登錄正常,但是退出的時(shí)候并沒有清掉session,退出后還是處于登錄狀態(tài)。解決方法如下:

路由如下

Route::group(['namespace' => 'Admin', 'middleware' => 'auth'], function() {
  Route::resource('admin/post', 'PostController');
});


// 登陸
Route::get('auth/login', 'Auth\AuthController@getLogin');
Route::post('auth/login', 'Auth\AuthController@postLogin');
// 5.2版本這里的方法需要寫成logout,因?yàn)樵谥虚g件中是這么定義的
public function __construct()
 { 
   $this->middleware($this->guestMiddleware(), ['except' => 'logout']);
 }
 // 路由中的方法要跟上述一致
Route::get('auth/logout', 'Auth\AuthController@logout');

AuthController.php中的

// 登錄成功后跳轉(zhuǎn)地址
protected $redirectTo = 'admin/post';
// 退出后跳轉(zhuǎn)地址
protected $redirectAfterLogout = 'auth/login';

參考 http://stackoverflow.com/questions/34479994/laravel-5-2-authlogout-is-not-working

調(diào)試過程中在AppserviceProvider的boot方法里添加輸出sql也會導(dǎo)致類似的錯(cuò)誤,所以在登錄調(diào)試時(shí),盡量不要這樣做

  /**
   * Bootstrap any application services.
   *
   * @return void
   */
  public function boot()
  {
    // \DB::listen(function($sql) {
    //     dump($sql->sql);
    //   });
  }

以上這篇解決Laravel5.2 Auth認(rèn)證退出失效的問題就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論