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

23 lines
471 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')) {
2016-08-29 23:08:09 +08:00
if (session('token') != (new User(session('uid')))->getToken()) {
2016-09-24 22:49:20 +08:00
Session::put('msg', trans('auth.check.token'));
2016-08-28 10:05:21 +08:00
} else {
2016-08-29 23:08:09 +08:00
return redirect('user');
2016-08-28 10:05:21 +08:00
}
}
return $next($request);
}
}