Update Auth.php

This commit is contained in:
Anyon 2020-11-24 18:25:47 +08:00
parent 57780a39b4
commit eaafaf8a10

View File

@ -48,13 +48,14 @@ abstract class Auth extends Controller
protected function getUser() protected function getUser()
{ {
try { try {
$user = UserService::instance();
if (empty($this->uuid)) { if (empty($this->uuid)) {
$token = input('token') ?: $this->request->header('token'); $token = input('token') ?: $this->request->header('token');
if (empty($token)) $this->error('接口认证令牌不能为空!'); if (empty($token)) $this->error('接口认证令牌不能为空!');
[$state, $message, $this->uuid] = UserService::instance()->checkUserToken($this->type, $token); [$state, $message, $this->uuid] = $user->checkUserToken($this->type, $token);
if (empty($state)) $this->error($message); if (empty($state)) $this->error($message);
} }
return UserService::instance()->get($this->type, $this->uuid); return $user->get($this->type, $this->uuid);
} catch (HttpResponseException $exception) { } catch (HttpResponseException $exception) {
throw $exception; throw $exception;
} catch (\Exception $exception) { } catch (\Exception $exception) {