diff --git a/web/assets/js/model/models.js b/web/assets/js/model/models.js index ace99f48..a3fd2633 100644 --- a/web/assets/js/model/models.js +++ b/web/assets/js/model/models.js @@ -172,6 +172,7 @@ class AllSetting { this.webCertFile = ""; this.webKeyFile = ""; this.webBasePath = "/"; + this.sessionMaxAge = ""; this.expireDiff = ""; this.trafficDiff = ""; this.tgBotEnable = false; diff --git a/web/controller/index.go b/web/controller/index.go index c19ee799..4776cefa 100644 --- a/web/controller/index.go +++ b/web/controller/index.go @@ -70,6 +70,16 @@ func (a *IndexController) login(c *gin.Context) { } else { logger.Infof("%s login success,Ip Address:%s\n", form.Username, getRemoteIp(c)) a.tgbot.UserLoginNotify(form.Username, getRemoteIp(c), timeStr, 1) + sessionMaxAge, err := a.settingService.GetSessionMaxAge() + if err != nil { + logger.Infof("Unable to get session's max age from DB") + } + + err = session.SetMaxAge(c, sessionMaxAge*60) + if err != nil { + logger.Infof("Unable to set session's max age") + } + } err = session.SetLoginUser(c, user) diff --git a/web/entity/entity.go b/web/entity/entity.go index f1b24520..b370b7ba 100644 --- a/web/entity/entity.go +++ b/web/entity/entity.go @@ -32,6 +32,7 @@ type AllSetting struct { WebCertFile string `json:"webCertFile" form:"webCertFile"` WebKeyFile string `json:"webKeyFile" form:"webKeyFile"` WebBasePath string `json:"webBasePath" form:"webBasePath"` + SessionMaxAge int `json:"sessionMaxAge" form:"sessionMaxAge"` ExpireDiff int `json:"expireDiff" form:"expireDiff"` TrafficDiff int `json:"trafficDiff" form:"trafficDiff"` TgBotEnable bool `json:"tgBotEnable" form:"tgBotEnable"` diff --git a/web/html/xui/component/setting.html b/web/html/xui/component/setting.html index 9f8e8cbc..00eeb259 100644 --- a/web/html/xui/component/setting.html +++ b/web/html/xui/component/setting.html @@ -9,7 +9,7 @@