|
@@ -662,6 +662,32 @@ func checkToken(c *BaseAuthController) (isOk bool, token string, resp models.Bas
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ // cookie过期逻辑
|
|
|
+ {
|
|
|
+ aiUserExpireStr := c.Ctx.GetCookie("expire")
|
|
|
+ if aiUserExpireStr == `` {
|
|
|
+ resp = models.BaseResponse{Ret: 408, Msg: "请重新授权!", ErrMsg: "expire empty"}
|
|
|
+ isOk = false
|
|
|
+ return
|
|
|
+ }
|
|
|
+ aiUserExpire, err := strconv.Atoi(aiUserExpireStr)
|
|
|
+ if err != nil {
|
|
|
+ resp = models.BaseResponse{Ret: 408, Msg: "请重新授权!", ErrMsg: "expire 异常"}
|
|
|
+ isOk = false
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 将毫秒时间戳转换为秒和纳秒
|
|
|
+ seconds := int64(aiUserExpire) / 1000
|
|
|
+ nanoseconds := (int64(aiUserExpire) % 1000) * 1e6
|
|
|
+
|
|
|
+ aiUserExpireTime := time.Unix(seconds, nanoseconds)
|
|
|
+ if aiUserExpireTime.Before(time.Now()) {
|
|
|
+ resp = models.BaseResponse{Ret: 408, Msg: "请重新授权!", ErrMsg: "cookie已过期"}
|
|
|
+ isOk = false
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 获取eta的token
|
|
|
authorization := c.Ctx.Input.Header("authorization")
|
|
|
if authorization == "" {
|