mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
[更新]刷新用户接口处理
This commit is contained in:
parent
5ba10b24ca
commit
3514055ed7
@ -14,7 +14,13 @@ use think\exception\HttpResponseException;
|
|||||||
abstract class Auth extends Controller
|
abstract class Auth extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 当前用户UID
|
* 当前接口类型
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前用户编号
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
protected $uuid;
|
protected $uuid;
|
||||||
@ -25,12 +31,6 @@ abstract class Auth extends Controller
|
|||||||
*/
|
*/
|
||||||
protected $user;
|
protected $user;
|
||||||
|
|
||||||
/**
|
|
||||||
* 当前接口类型
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $type;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 控制器初始化
|
* 控制器初始化
|
||||||
*/
|
*/
|
||||||
@ -44,18 +44,18 @@ abstract class Auth extends Controller
|
|||||||
* 获取用户数据
|
* 获取用户数据
|
||||||
* @return array|void
|
* @return array|void
|
||||||
*/
|
*/
|
||||||
protected function getUser()
|
protected function getUser(): array
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$user = UserService::instance();
|
|
||||||
$this->type = input('api', 'web');
|
$this->type = input('api', 'web');
|
||||||
|
$service = 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] = $user->checkUserToken($this->type, $token);
|
[$state, $info, $this->uuid] = $service->checkUserToken($this->type, $token);
|
||||||
if (empty($state)) $this->error($message);
|
if (empty($state)) $this->error($info, '{-null-}', 401);
|
||||||
}
|
}
|
||||||
return $user->get($this->type, $this->uuid);
|
return $service->get($this->type, $this->uuid);
|
||||||
} catch (HttpResponseException $exception) {
|
} catch (HttpResponseException $exception) {
|
||||||
throw $exception;
|
throw $exception;
|
||||||
} catch (\Exception $exception) {
|
} catch (\Exception $exception) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user