Initial commit

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
fish03
2026-09-23 14:43:16 +07:00
co-authored by Claude Opus 5.5
commit bef9f8b4ed
663 changed files with 81305 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
package web
import (
"videoweb/app/service/authser"
"github.com/gin-gonic/gin"
)
// AbortSSRIfSessionExpired 处理 SSR 场景下的会话失效码。
// aborted=true:已跳转登录,调用方应立刻 return;
// retry=true:游客已重新登录,调用方应重试上游请求。
func AbortSSRIfSessionExpired(c *gin.Context, code int) (aborted, retry bool) {
if !authser.IsSessionExpiredCode(code) {
return false, false
}
retry, needLogin := authser.OnSessionExpired(c, code)
if needLogin {
RedirectToLogin(c)
return true, false
}
return false, retry
}
// TryJSONSessionRecover JSON 接口遇到会话失效时:游客重登后返回 true(应重试);
// 注册账号清 cookie 后返回 false,调用方继续把 code=1000 交给前端弹登录。
func TryJSONSessionRecover(c *gin.Context, code int) bool {
if !authser.IsSessionExpiredCode(code) {
return false
}
retry, _ := authser.OnSessionExpired(c, code)
return retry
}