15m44z 续(19:59):修 GitHub 授权误导 —— 刚授权却提示「token 可能已失效」

gh_cfg.php:加 gh_token_fresh 判定(OAuth 回调 updated_at <5min → 免 /user 验活,必有效);
根治 CF 边缘 /user 验活偶发 401/卡住把刚授权的有效 token 误判成失效。
token 保留兜底只对「老 token 验活 401」生效,刚授权(fresh)不进入该分支。
player.php:按 gh_token_fresh 区分文案 —— 刚授权显示「已授权 token 有效」,
老 token 失效才显示「授权已保留,token 可能已失效」。
This commit is contained in:
ypsdf1
2026-11-26 20:04:19 +08:00
parent b32b6ed9ef
commit 8c9b8a10d9
2 changed files with 41 additions and 11 deletions
+12 -1
View File
@@ -4002,11 +4002,22 @@ if ($currentVersion !== $BUILD_VERSION) {
// - 匿名模式可用 + gh_authorized=true → "授权已保留(可重新授权)"
// - 匿名模式不可用 + gh_authorized=true → "已授权,自动同步"(老态)
if (isAuthed) {
if (d.gh_anon_available === true) {
// ★ 15m44z 续(19:59):按 gh_token_fresh 区分「刚授权(必有效)」vs「老 token(可能失效)」。
// 刚走完 gh_oauth 回调(updated_at <5min)→ gh_token_fresh=true → 显示「已授权」,
// 根治「刚授权却提示 token 可能已失效」的误导(CF 验活偶发 401 把有效 token 误判)。
const tokenFresh = d.gh_token_fresh === true;
if (tokenFresh) {
// 刚授权 = 必有效,不显示「可能失效」
if (txt) txt.textContent = '✅ GitHub 已授权,工单+附件会自动同步到 issue';
if (sub) sub.textContent = '刚完成授权,token 有效,工单提交将自动同步到 GitHub issue';
if (btn) { btn.textContent = '重新授权'; btn.onclick = gotoGhOAuth; }
} else if (d.gh_anon_available === true) {
// 老 token 失效 + 匿名通道可用 → 已保留授权记录(可重新授权或走匿名)
if (txt) txt.textContent = '🔗 GitHub 授权已保留,切匿名模式不影响授权记录';
if (sub) sub.textContent = '实名通道 token 可能已失效,点重新授权可刷新;切匿名模式走系统机器人,无需玩家授权';
if (btn) { btn.textContent = '重新授权'; btn.onclick = gotoGhOAuth; }
} else {
// 老 token 失效 + 无匿名通道
if (txt) txt.textContent = '✅ GitHub 已授权,工单+附件会自动同步到 issue';
if (sub) sub.textContent = '当前账号 token 有效,工单提交将自动同步到 GitHub issue';
if (btn) { btn.textContent = '重新授权'; btn.onclick = gotoGhOAuth; }