blessing-skin-server/app/Http/Middleware/RedirectIfAuthenticated.php
2016-10-25 21:35:09 +08:00

24 lines
487 B
PHP

<?php
namespace App\Http\Middleware;
use App;
use Session;
use App\Models\User;
class RedirectIfAuthenticated
{
public function handle($request, \Closure $next)
{
if (session()->has('uid')) {
if (session('token') != app('users')->get(session('uid'))->getToken()) {
Session::put('msg', trans('auth.check.token'));
} else {
return redirect('user');
}
}
return $next($request);
}
}