41 lines
866 B
PHP
41 lines
866 B
PHP
<?php
|
|
|
|
namespace app\controller\admin\auth;
|
|
|
|
use app\BaseController;
|
|
use app\entity\SysUser;
|
|
use think\db\exception\DataNotFoundException;
|
|
use think\db\exception\DbException;
|
|
use think\db\exception\ModelNotFoundException;
|
|
use think\response\Json;
|
|
|
|
/**
|
|
* 用户Auth控制器
|
|
*/
|
|
class AuthController extends BaseController
|
|
{
|
|
/**
|
|
* 查询用户信息
|
|
* @return Json
|
|
* @throws DataNotFoundException
|
|
* @throws DbException
|
|
* @throws ModelNotFoundException
|
|
*/
|
|
public function user(): Json
|
|
{
|
|
$user = SysUser::findOrFail($this->auth->userId);
|
|
$data = $user->append(['authorities', 'roles'])->toArray();
|
|
|
|
return $this->writeSuccess('', $data);
|
|
}
|
|
|
|
/**
|
|
* 退出登录
|
|
* @return Json
|
|
*/
|
|
public function logout(): Json
|
|
{
|
|
return $this->writeSuccess('退出成功');
|
|
}
|
|
}
|