Skip to content

Commit

Permalink
improve: 修改 sqlDB.SetConnMaxLifetime 为 1h
Browse files Browse the repository at this point in the history
  • Loading branch information
Mmx233 committed Dec 22, 2023
1 parent 0d0dc58 commit a19c884
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions internal/api/controllers/public/login/passkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,15 @@ func FinishPasskeyLogin(c *gin.Context) {
return
}

claims := jwtClaims.LoginRedis{
token, err := jwt.GenerateLoginToken(jwtClaims.LoginRedis{
UID: user.ID,
Name: user.Name,
IP: c.ClientIP(),
Useragent: c.Request.UserAgent(),
Groups: groups,
AppID: appInfo.ID,
AvatarUrl: user.AvatarUrl,
}

token, err := jwt.GenerateLoginToken(claims)
})
if err != nil {
callback.Error(c, callback.ErrUnexpected, err)
return
Expand Down
2 changes: 1 addition & 1 deletion pkg/drivers/mysql/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func New(conf *Config, gormConfig *gorm.Config) (*gorm.DB, error) {

//连接池设置
if sqlDB, err := db.DB(); err == nil {
sqlDB.SetConnMaxLifetime(time.Hour * 5)
sqlDB.SetConnMaxIdleTime(time.Hour)
}

return db, nil
Expand Down

0 comments on commit a19c884

Please sign in to comment.