1Panel/backend/middleware/helper.go
ssongliu 7fb41f43cc
Some checks failed
Build / SonarCloud (push) Failing after -5m2s
sync2gitee / repo-sync (push) Failing after -5m3s
Build Test / build-linux-binary (push) Failing after 7s
fix: 解决登录页跳转空白的问题 (#5285)
2024-06-04 14:29:05 +00:00

32 lines
626 B
Go

package middleware
import (
"net/http"
"github.com/1Panel-dev/1Panel/backend/app/repo"
)
func LoadErrCode(errInfo string) int {
settingRepo := repo.NewISettingRepo()
codeVal, err := settingRepo.Get(settingRepo.WithByKey("NoAuthSetting"))
if err != nil {
return 500
}
switch codeVal.Value {
case "400":
return http.StatusBadRequest
case "401":
return http.StatusUnauthorized
case "403":
return http.StatusForbidden
case "404":
return http.StatusNotFound
case "408":
return http.StatusRequestTimeout
case "416":
return http.StatusRequestedRangeNotSatisfiable
default:
return http.StatusOK
}
}