API接口

1.新增鉴权接口/api/v1/authToken
2.修复注册,登录,获取首页初始化数据,获取用户信息接口报错
This commit is contained in:
2026-04-16 18:42:44 +08:00
parent 5ee0f2b1f4
commit cfe5ec6fb0
12 changed files with 93 additions and 60 deletions

View File

@@ -36,7 +36,13 @@ class Frontend extends Api
try {
$this->auth = Auth::instance(['request' => $request]);
$token = get_auth_token(['ba', 'user', 'token'], $request);
$token = trim((string) $request->header('user-token', ''));
if ($token === '') {
$token = trim((string) $request->header('user_token', ''));
}
if ($token === '') {
$token = get_auth_token(['ba', 'user', 'token'], $request);
}
if ($token) $this->auth->init($token);
} catch (TokenExpirationException) {
if ($needLogin) return $this->error(__('Token expiration'), [], 409);