fix: 修复 Apple 登录 sub claim 映射 + 按钮文案中文化

- AppleTokenValidator: 从 JwtSecurityToken 原始 Claims 取 sub,避免 .NET ClaimType 映射导致丢失
- 登录页 Apple 按钮改为中文"通过 Apple 登录"

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
sccsbc
2026-07-10 13:35:28 +08:00
parent fe4c81c54f
commit bd4350c17f
2 changed files with 4 additions and 2 deletions

View File

@@ -49,8 +49,9 @@ public sealed class AppleTokenValidator
ClockSkew = TimeSpan.FromMinutes(1), ClockSkew = TimeSpan.FromMinutes(1),
}; };
var principal = handler.ValidateToken(identityToken, validationParams, out _); handler.ValidateToken(identityToken, validationParams, out _);
var sub = principal.FindFirst("sub")?.Value; // 从原始 JWT 取 sub避免 .NET 的 ClaimType 映射把 "sub" 转成 NameIdentifier
var sub = rawToken.Claims.FirstOrDefault(c => c.Type == "sub")?.Value;
if (string.IsNullOrWhiteSpace(sub)) if (string.IsNullOrWhiteSpace(sub))
throw new SecurityTokenException("Missing 'sub' claim in Apple identityToken"); throw new SecurityTokenException("Missing 'sub' claim in Apple identityToken");

View File

@@ -563,6 +563,7 @@ class _LoginPageState extends ConsumerState<LoginPage> {
onPressed: _loading ? () {} : () { _appleSignIn(); }, onPressed: _loading ? () {} : () { _appleSignIn(); },
style: SignInWithAppleButtonStyle.whiteOutlined, style: SignInWithAppleButtonStyle.whiteOutlined,
height: 48, height: 48,
text: '通过 Apple 登录',
), ),
], ],
const SizedBox(height: 16), const SizedBox(height: 16),