yangjianbo
39433f2a29
fix(auth): 修复 RefreshToken 使用过期 token 时的 nil pointer panic
问题分析:
- RefreshToken 允许过期 token 继续流程(用于无感刷新)
- 但 ValidateToken 在 token 过期时返回 nil claims
- 导致后续访问 claims.UserID 时触发 panic
修复方案:
- 修改 ValidateToken,在检测到 ErrTokenExpired 时仍然返回 claims
- jwt-go 在解析时即使遇到过期错误,token.Claims 仍会被填充
- 这样 RefreshToken 可以正常获取用户信息并生成新 token
新增测试:
- TestAuthService_ValidateToken_ExpiredReturnsClaimsWithError
- TestAuthService_RefreshToken_ExpiredTokenNoPanic
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 09:36:06 +08:00
..
2026-01-07 16:59:35 +08:00
2026-01-07 16:59:35 +08:00
2026-01-07 16:59:35 +08:00
2026-01-08 23:47:29 +08:00
2026-01-06 22:19:07 +08:00
2026-01-07 16:59:35 +08:00
2026-01-01 18:59:38 +08:00
2026-01-08 21:44:18 +08:00
2026-01-05 17:07:29 +08:00
2026-01-08 23:13:57 +08:00
2026-01-05 00:56:48 +08:00
2026-01-08 20:06:32 +08:00
2026-01-05 17:14:06 +08:00
2026-01-03 06:29:02 -08:00
2026-01-03 06:29:02 -08:00
2026-01-04 19:28:20 +08:00
2026-01-04 19:28:20 +08:00
2026-01-04 19:28:20 +08:00
2026-01-09 09:36:06 +08:00
2026-01-09 09:36:06 +08:00
2026-01-04 22:10:32 +08:00
2026-01-05 17:07:29 +08:00
2026-01-05 17:07:29 +08:00
2026-01-08 23:07:00 +08:00
2026-01-03 06:32:51 -08:00
2026-01-05 14:41:08 +08:00
2026-01-04 19:28:20 +08:00
2026-01-04 22:49:40 +08:00
2026-01-06 11:36:38 +08:00
2026-01-08 23:13:57 +08:00
2026-01-04 10:45:18 +08:00
2026-01-05 00:56:48 +08:00
2026-01-04 18:26:39 -08:00
2026-01-08 23:07:00 +08:00
2026-01-08 23:07:00 +08:00
2026-01-08 23:13:57 +08:00
2026-01-08 23:47:29 +08:00
2026-01-08 23:47:29 +08:00
2026-01-04 15:36:00 +08:00
2026-01-01 04:29:22 +08:00
2026-01-05 17:07:29 +08:00
2026-01-08 23:07:00 +08:00
2026-01-05 14:41:08 +08:00
2026-01-08 23:07:00 +08:00
2026-01-06 10:49:26 +08:00
2026-01-08 21:20:12 +08:00
2026-01-03 06:29:02 -08:00
2026-01-04 15:36:00 +08:00
2026-01-04 23:17:15 +08:00
2026-01-04 23:17:15 +08:00
2026-01-03 06:34:00 -08:00
2026-01-04 15:59:21 +08:00
2026-01-04 19:28:20 +08:00
2026-01-04 19:28:20 +08:00
2026-01-07 22:49:46 +08:00
2026-01-06 22:19:07 +08:00
2026-01-03 06:37:08 -08:00
2026-01-01 18:58:34 +08:00
2026-01-01 19:09:06 +08:00
2026-01-04 19:28:20 +08:00
2026-01-07 16:59:35 +08:00