优化 Request 认证
This commit is contained in:
parent
19c092dffc
commit
32b87baeee
@ -18,16 +18,17 @@ class Request extends \think\Request
|
||||
* login user
|
||||
*
|
||||
* @time 2020年01月09日
|
||||
* @param null $guard
|
||||
* @return mixed
|
||||
*/
|
||||
public function user()
|
||||
public function user($guard = null)
|
||||
{
|
||||
if (!$this->auth) {
|
||||
$this->auth = new CatchAuth;
|
||||
}
|
||||
|
||||
try {
|
||||
$user = $this->auth->user();
|
||||
$user = $this->auth->guard($guard ? : config('catch.auth.default.guard'))->user();
|
||||
} catch (\Exception $e) {
|
||||
if ($e instanceof TokenExpiredException) {
|
||||
throw new FailedException('token 过期', Code::LOGIN_EXPIRED);
|
||||
|
Loading…
x
Reference in New Issue
Block a user