mirror of
https://gitee.com/fit2cloud-feizhiyun/1Panel.git
synced 2026-11-19 19:34:49 +08:00
feat: adjust internationalization errors and the positions of global … (#7767)
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||
"github.com/1Panel-dev/1Panel/agent/constant"
|
||||
"github.com/1Panel-dev/1Panel/agent/global"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@@ -17,12 +16,12 @@ func Certificate() gin.HandlerFunc {
|
||||
return
|
||||
}
|
||||
if !c.Request.TLS.HandshakeComplete || len(c.Request.TLS.PeerCertificates) == 0 {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, errors.New("no such tls peer certificates"))
|
||||
helper.InternalServer(c, errors.New("no such tls peer certificates"))
|
||||
return
|
||||
}
|
||||
cert := c.Request.TLS.PeerCertificates[0]
|
||||
if cert.Subject.CommonName != "panel_client" {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, fmt.Errorf("err certificate"))
|
||||
helper.InternalServer(c, fmt.Errorf("err certificate"))
|
||||
return
|
||||
}
|
||||
c.Next()
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
|
||||
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||
"github.com/1Panel-dev/1Panel/agent/buserr"
|
||||
"github.com/1Panel-dev/1Panel/agent/constant"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
@@ -51,7 +50,7 @@ func DemoHandle() gin.HandlerFunc {
|
||||
|
||||
c.JSON(http.StatusInternalServerError, dto.Response{
|
||||
Code: http.StatusInternalServerError,
|
||||
Message: buserr.New(constant.ErrDemoEnvironment).Error(),
|
||||
Message: buserr.New("ErrDemoEnvironment").Error(),
|
||||
})
|
||||
c.Abort()
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||
"github.com/1Panel-dev/1Panel/agent/app/repo"
|
||||
"github.com/1Panel-dev/1Panel/agent/constant"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
@@ -12,11 +13,11 @@ func GlobalLoading() gin.HandlerFunc {
|
||||
settingRepo := repo.NewISettingRepo()
|
||||
status, err := settingRepo.Get(settingRepo.WithByKey("SystemStatus"))
|
||||
if err != nil {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||
helper.InternalServer(c, err)
|
||||
return
|
||||
}
|
||||
if status.Value != "Free" {
|
||||
helper.ErrorWithDetail(c, constant.CodeGlobalLoading, status.Value, err)
|
||||
helper.ErrorWithDetail(c, http.StatusProxyAuthRequired, status.Value, err)
|
||||
return
|
||||
}
|
||||
c.Next()
|
||||
|
||||
Reference in New Issue
Block a user