mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-02-28 11:04:14 +08:00
fix: Fix the issue with the homepage route refresh (#7974)
This commit is contained in:
parent
b1f337020c
commit
872a93aa07
@ -66,6 +66,10 @@ func (b *BaseApi) UpdateSetting(c *gin.Context) {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||
return
|
||||
}
|
||||
if req.Key == "SecurityEntrance" {
|
||||
entranceValue := base64.StdEncoding.EncodeToString([]byte(req.Value))
|
||||
c.SetCookie("SecurityEntrance", entranceValue, 0, "", "", false, true)
|
||||
}
|
||||
helper.SuccessWithData(c, nil)
|
||||
}
|
||||
|
||||
|
@ -109,6 +109,15 @@ func handleNoRoute(c *gin.Context) {
|
||||
c.Data(statusCode, "text/html; charset=utf-8", data)
|
||||
}
|
||||
|
||||
func checkSession(c *gin.Context) bool {
|
||||
sId, err := c.Cookie(constant.SessionName)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
_, err = global.SESSION.Get(sId)
|
||||
return err == nil
|
||||
}
|
||||
|
||||
func setWebStatic(rootRouter *gin.RouterGroup) {
|
||||
rootRouter.StaticFS("/public", http.FS(web.Favicon))
|
||||
rootRouter.StaticFS("/favicon.ico", http.FS(web.Favicon))
|
||||
@ -136,10 +145,15 @@ func setWebStatic(rootRouter *gin.RouterGroup) {
|
||||
})
|
||||
}
|
||||
rootRouter.GET("/", func(c *gin.Context) {
|
||||
if !checkEntrance(c) {
|
||||
if !checkEntrance(c) && !checkSession(c) {
|
||||
handleNoRoute(c)
|
||||
return
|
||||
}
|
||||
entrance = authService.GetSecurityEntrance()
|
||||
if entrance != "" {
|
||||
entranceValue := base64.StdEncoding.EncodeToString([]byte(entrance))
|
||||
c.SetCookie("SecurityEntrance", entranceValue, 0, "", "", false, true)
|
||||
}
|
||||
staticServer := http.FileServer(http.FS(web.IndexHtml))
|
||||
staticServer.ServeHTTP(c.Writer, c.Request)
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user