2016-08-28 10:05:21 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
|
2016-10-23 11:41:52 +08:00
|
|
|
use App;
|
2016-08-28 10:05:21 +08:00
|
|
|
use Session;
|
2016-10-23 11:41:52 +08:00
|
|
|
use App\Models\User;
|
2016-08-28 10:05:21 +08:00
|
|
|
|
|
|
|
class RedirectIfAuthenticated
|
|
|
|
{
|
|
|
|
public function handle($request, \Closure $next)
|
|
|
|
{
|
|
|
|
if (session()->has('uid')) {
|
2016-10-25 21:35:09 +08:00
|
|
|
if (session('token') != app('users')->get(session('uid'))->getToken()) {
|
2017-10-29 09:19:02 +08:00
|
|
|
Session::put('msg', trans('auth.check.token')); // @codeCoverageIgnore
|
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);
|
|
|
|
}
|
|
|
|
}
|