logo和配置修改
This commit is contained in:
+2
-22
@@ -6,27 +6,7 @@ import (
|
||||
"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 交给前端弹登录。
|
||||
// TryJSONSessionRecover 上游返回会话失效时重建游客会话;返回 true 表示调用方应重试一次。
|
||||
func TryJSONSessionRecover(c *gin.Context, code int) bool {
|
||||
if !authser.IsSessionExpiredCode(code) {
|
||||
return false
|
||||
}
|
||||
retry, _ := authser.OnSessionExpired(c, code)
|
||||
return retry
|
||||
return authser.RecoverContentSession(c, code)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user