Skip to content

Commit

Permalink
fix: 登录状态未保留与 accessToken 保留时长错误
Browse files Browse the repository at this point in the history
  • Loading branch information
Mmx233 committed Nov 30, 2023
1 parent da270db commit 2f4c163
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/api/middlewares/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func Auth() (gin.HandlerFunc, error) {
case "/login":
token, ok := c.GetQuery("token")
if !ok {
tokenCookie, err := c.Cookie("token")
tokenCookie, err := c.Cookie("refresh_token")
if err != nil || tokenCookie == "" {
util.GoGeniusLogin(c)
} else {
Expand All @@ -58,7 +58,7 @@ func Auth() (gin.HandlerFunc, error) {

// refreshToken 不能一直发送到服务端,但是此处没有前端不好写,先临时这样处理
c.SetCookie("refreshToken", gaRes.Data.RefreshToken, int(validate), "", "", true, true)
c.SetCookie("accessToken", gaRes.Data.AccessToken, int(time.Minute*5), "", "", true, true)
c.SetCookie("accessToken", gaRes.Data.AccessToken, int((time.Minute * 5).Seconds()), "", "", true, true)
c.Redirect(302, "/")
default:
for _, whiteListPath := range global.WhiteListPath {
Expand Down Expand Up @@ -92,7 +92,7 @@ func Auth() (gin.HandlerFunc, error) {
return
}
} else {
c.SetCookie("accessToken", result.AccessToken, int(time.Minute*5), "", "", true, true)
c.SetCookie("accessToken", result.AccessToken, int((time.Minute * 5).Seconds()), "", "", true, true)
return
}
}
Expand Down

0 comments on commit 2f4c163

Please sign in to comment.