Commit 0089f13b by zhangxingmin

push

parent 90ffae97
......@@ -27,6 +27,7 @@ import org.springframework.util.StringUtils;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.time.LocalDateTime;
......@@ -88,8 +89,17 @@ public class ApiSubscribeRecordServiceImpl implements ApiSubscribeRecordService
throw new RuntimeException("未提供认证 Token");
}
// ----- 通用提取逻辑:取最后一个空格之后的部分,兼容任意前缀(如 "zuihuibi "、"Bearer " 等)-----
String token = authorization;
int lastSpaceIndex = authorization.lastIndexOf(" ");
if (lastSpaceIndex != -1) {
token = authorization.substring(lastSpaceIndex + 1);
log.info("认证头包含前缀,已自动提取 Token 部分(原头:{})", authorization);
}
// ----------------------------------------------------------------------------------------
// 1. 解析 Token 获取用户 ID
String userIdStr = SfpTokenUtil.getUserIdFromToken(authorization);
String userIdStr = SfpTokenUtil.getUserIdFromToken(token);
if (!StringUtils.hasText(userIdStr)) {
log.error("Token 解析失败,未获取到用户 ID");
throw new RuntimeException("Token 无效");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment