fix(auth): fail loudly on JWT encode error instead of returning empty token

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
cc 2026-06-24 21:00:21 +08:00
parent e1820d0ec8
commit 1186d80475

View File

@ -217,7 +217,7 @@ fn sign(secret: &[u8], username: &str, exp: usize) -> String {
&claims, &claims,
&EncodingKey::from_secret(secret), &EncodingKey::from_secret(secret),
) )
.unwrap_or_default() .expect("JWT 编码失败")
} }
/// 用指定密钥校验 JWT便于测试。默认校验 `exp`。 /// 用指定密钥校验 JWT便于测试。默认校验 `exp`。