Redirect - Laravel 5.2 The session is lost after the middleware redirects to verify login timeout?
过去多啦不再A梦
过去多啦不再A梦 2017-05-16 16:51:22
0
1
1099

public function handle($request, Closure $next, $guard = 'manager')

{ if (!Auth::guard($guard)->check()) { return redirect('manager/login'); } if (config('misc.session_timeout_status')) { $isLoggedIn = $request->path() != '/manager/logout'; if (!session('lastActivityTime')) { $this->session->put('lastActivityTime', time()); } elseif (time() - $this->session->get('lastActivityTime') > $this->timeout) { debugbar()->info('时间到!'.$this->timeout); log::info('时间到!'.$this->timeout); $this->session->forget('lastActivityTime'); $cookie = cookie('intend', $isLoggedIn ? url()->current() : 'manager/'); $email = Auth::guard($guard)->user()->email; session()->flash('flash_danger', '您自动登出是出于安全原因,因为您' . $this->timeout / 60 . '分钟内没有活动。'); Auth::guard($guard)->logout(); return redirect()->to('/manager/login')->withErrors('您自动登出是出于安全原因,因为您' . $this->timeout / 60 . '分钟内没有活动。')->withInput(compact('email'))->withCookie($cookie); } $isLoggedIn ? $this->session->put('lastActivityTime', time()) : $this->session->forget('lastActivityTime'); } return $next($request); } redirect后session或error都没值了,login接收不到数据,路由如下:

Route::group(['namespace' => 'Manager', 'prefix' => 'manager'], function () {

Route::auth(); Route::group([ 'middleware' => ['admin'], ], function () { Route::get('/', 'HomeController@index'); Route::resource('article', 'ArticleController'); });

});

不知道哪里出问题了。
过去多啦不再A梦
过去多啦不再A梦

reply all (1)
Peter_Zhu

Middle component 'middleware' => ['admin'], caused

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!