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

24 lines
513 B
PHP
Raw Normal View History

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()) {
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);
}
}