更新路由配置和登录界面接口

This commit is contained in:
2026-02-06 20:29:35 +08:00
parent 776aacfa2e
commit badc502fbb
3 changed files with 25 additions and 8 deletions
+23 -8
View File
@@ -9,9 +9,11 @@ use think\exception\ValidateException;
use think\facade\Db;
use think\facade\Cache;
use think\response\Json;
use app\model\AdminUser;
use app\service\JwtService;
use app\model\AdminUser;
use app\model\System\SystemSiteSettings;
class LoginController extends BaseController
{
private function generateToken($userInfo): string
@@ -103,7 +105,7 @@ class LoginController extends BaseController
{
$authHeader = $this->request->header('Authorization', '');
$userInfo = null;
if (preg_match('/Bearer\s+(.+)/i', $authHeader, $matches)) {
$tokenData = $this->verifyToken($matches[1]);
if ($tokenData && isset($tokenData['user'])) {
@@ -145,7 +147,7 @@ class LoginController extends BaseController
public function userInfo(): Json
{
$authHeader = $this->request->header('Authorization', '');
if (!preg_match('/Bearer\s+(.+)/i', $authHeader, $matches)) {
return json([
'code' => 401,
@@ -154,7 +156,7 @@ class LoginController extends BaseController
}
$tokenData = $this->verifyToken($matches[1]);
if (!$tokenData || !isset($tokenData['user'])) {
return json([
'code' => 401,
@@ -183,9 +185,22 @@ class LoginController extends BaseController
'data' => $userData->toArray()
]);
}
public function getAdminUserFromToken(): array
{
return JwtService::getUserFromHeader($this->request->header('Authorization', ''));
}
{
return JwtService::getUserFromHeader($this->request->header('Authorization', ''));
}
public function loginInfo()
{
$loginInfo = SystemSiteSettings::select();
return json([
'code' => 200,
'msg' => '获取成功',
'data' => $loginInfo
]);
}
}