blessing-skin-server/app/Http/Middleware/RedirectIfAuthenticated.php

24 lines
497 B
PHP
Raw Normal View History

2016-08-28 10:05:21 +08:00
<?php
namespace App\Http\Middleware;
use App\Models\User;
use Session;
class RedirectIfAuthenticated
{
public function handle($request, \Closure $next)
{
if (session()->has('uid')) {
if (session('token') != (new User(session('uid')))->getToken())
{
Session::put('msg', '无效的 token请重新登录~');
} else {
\Http::redirect('../user');
}
}
return $next($request);
}
}