blessing-skin-server/app/Http/Middleware/RedirectIfAuthenticated.php
2016-08-29 23:12:45 +08:00

23 lines
482 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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 {
return redirect('user');
}
}
return $next($request);
}
}