mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-31 14:08:06 +08:00
fix: 解决登录页跳转空白的问题 (#5285)
This commit is contained in:
parent
0afc6242a2
commit
7fb41f43cc
@ -124,9 +124,13 @@ func (b *BaseApi) CheckIsSafety(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
if status == "unpass" {
|
||||
if middleware.LoadErrCode("err-entrance") != 200 {
|
||||
helper.ErrResponse(c, middleware.LoadErrCode("err-entrance"))
|
||||
return
|
||||
}
|
||||
helper.ErrorWithDetail(c, constant.CodeErrEntrance, constant.ErrTypeInternalServer, nil)
|
||||
return
|
||||
}
|
||||
helper.SuccessWithOutData(c)
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
||||
@ -28,9 +29,13 @@ func BindDomain() gin.HandlerFunc {
|
||||
}
|
||||
|
||||
if domains != status.Value {
|
||||
if LoadErrCode("err-domain") != 200 {
|
||||
helper.ErrResponse(c, LoadErrCode("err-domain"))
|
||||
return
|
||||
}
|
||||
helper.ErrorWithDetail(c, constant.CodeErrDomain, constant.ErrTypeInternalServer, errors.New("domain not allowed"))
|
||||
return
|
||||
}
|
||||
c.Next()
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/backend/app/repo"
|
||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
||||
)
|
||||
|
||||
func LoadErrCode(errInfo string) int {
|
||||
@ -22,21 +21,12 @@ func LoadErrCode(errInfo string) int {
|
||||
case "403":
|
||||
return http.StatusForbidden
|
||||
case "404":
|
||||
return http.StatusFound
|
||||
return http.StatusNotFound
|
||||
case "408":
|
||||
return http.StatusRequestTimeout
|
||||
case "416":
|
||||
return http.StatusRequestedRangeNotSatisfiable
|
||||
default:
|
||||
if errInfo == "err-ip" {
|
||||
return constant.CodeErrIP
|
||||
}
|
||||
if errInfo == "err-domain" {
|
||||
return constant.CodeErrDomain
|
||||
}
|
||||
if errInfo == "err-entrance" {
|
||||
return constant.CodeErrEntrance
|
||||
}
|
||||
return http.StatusOK
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
@ -34,7 +35,11 @@ func WhiteAllow() gin.HandlerFunc {
|
||||
return
|
||||
}
|
||||
}
|
||||
if LoadErrCode("err-ip") != 200 {
|
||||
helper.ErrResponse(c, LoadErrCode("err-ip"))
|
||||
return
|
||||
}
|
||||
helper.ErrorWithDetail(c, constant.CodeErrIP, constant.ErrTypeInternalServer, errors.New("IP address not allowed"))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,11 +33,11 @@ func PasswordExpired() gin.HandlerFunc {
|
||||
loc, _ := time.LoadLocation(common.LoadTimeZone())
|
||||
expiredTime, err := time.ParseInLocation("2006-01-02 15:04:05", extime.Value, loc)
|
||||
if err != nil {
|
||||
helper.ErrResponse(c, constant.CodePasswordExpired)
|
||||
helper.ErrorWithDetail(c, constant.CodePasswordExpired, constant.ErrTypePasswordExpired, err)
|
||||
return
|
||||
}
|
||||
if time.Now().After(expiredTime) {
|
||||
helper.ErrResponse(c, constant.CodePasswordExpired)
|
||||
helper.ErrorWithDetail(c, constant.CodePasswordExpired, constant.ErrTypePasswordExpired, err)
|
||||
return
|
||||
}
|
||||
c.Next()
|
||||
|
@ -55,6 +55,22 @@ class RequestHttp {
|
||||
globalStore.errStatus = 'err-found';
|
||||
return;
|
||||
}
|
||||
if (data.code == ResultEnum.ERRIP) {
|
||||
globalStore.errStatus = 'err-ip';
|
||||
return;
|
||||
}
|
||||
if (data.code == ResultEnum.ERRDOMAIN) {
|
||||
globalStore.errStatus = 'err-domain';
|
||||
return;
|
||||
}
|
||||
if (data.code == ResultEnum.UNSAFETY) {
|
||||
globalStore.errStatus = 'err-unsafe';
|
||||
return;
|
||||
}
|
||||
if (data.code == ResultEnum.EXPIRED) {
|
||||
globalStore.errStatus = 'err-entrance';
|
||||
return;
|
||||
}
|
||||
if (data.code == ResultEnum.ERRXPACK) {
|
||||
globalStore.isProductPro = false;
|
||||
window.location.reload();
|
||||
@ -109,7 +125,6 @@ class RequestHttp {
|
||||
router.push({ name: 'Expired' });
|
||||
return;
|
||||
case 500:
|
||||
case 400:
|
||||
case 407:
|
||||
checkStatus(
|
||||
response.status,
|
||||
@ -122,6 +137,7 @@ class RequestHttp {
|
||||
name: 'entrance',
|
||||
params: { code: globalStore.entrance },
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!window.navigator.onLine) router.replace({ path: '/500' });
|
||||
|
@ -19,17 +19,20 @@ const props = defineProps({
|
||||
code: String,
|
||||
});
|
||||
const loadErrInfo = () => {
|
||||
console.log(props.code);
|
||||
switch (props.code) {
|
||||
case '400':
|
||||
return '400 Bad Request';
|
||||
case '401':
|
||||
return '401 Unauthorized';
|
||||
case '403':
|
||||
return '403 Forbidden';
|
||||
case '404':
|
||||
return '403 Not Found';
|
||||
return '404 Not Found';
|
||||
case '408':
|
||||
return '408 Request Timeout';
|
||||
case '416':
|
||||
return '408 Requested Not Satisfiable';
|
||||
return '416 Requested Not Satisfiable';
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -83,21 +83,8 @@ const getStatus = async () => {
|
||||
loading.value = false;
|
||||
loadDataFromXDB();
|
||||
})
|
||||
.catch((err) => {
|
||||
.catch(() => {
|
||||
loading.value = false;
|
||||
switch (err.response.status) {
|
||||
case 310:
|
||||
errStatus.value = 'err-ip';
|
||||
return;
|
||||
case 311:
|
||||
errStatus.value = 'err-domain';
|
||||
return;
|
||||
case 312:
|
||||
errStatus.value = 'err-entrance';
|
||||
return;
|
||||
default:
|
||||
errStatus.value = 'code-' + err.response.status;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user