mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-11-27 12:39:01 +08:00
parent
5c7fab8f01
commit
67c1fbd07a
@ -2,6 +2,7 @@ package v1
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"net/http"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
||||
@ -120,12 +121,13 @@ func (b *BaseApi) CheckIsSafety(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
if status == "disable" && len(code) != 0 {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrNotFound, constant.ErrTypeInternalServer, err)
|
||||
helper.ErrResponse(c, http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
if status == "unpass" {
|
||||
if middleware.LoadErrCode("err-entrance") != 200 {
|
||||
helper.ErrResponse(c, middleware.LoadErrCode("err-entrance"))
|
||||
code := middleware.LoadErrCode()
|
||||
if code != 200 {
|
||||
helper.ErrResponse(c, code)
|
||||
return
|
||||
}
|
||||
helper.ErrorWithDetail(c, constant.CodeErrEntrance, constant.ErrTypeInternalServer, nil)
|
||||
|
@ -29,8 +29,9 @@ func BindDomain() gin.HandlerFunc {
|
||||
}
|
||||
|
||||
if domains != status.Value {
|
||||
if LoadErrCode("err-domain") != 200 {
|
||||
helper.ErrResponse(c, LoadErrCode("err-domain"))
|
||||
code := LoadErrCode()
|
||||
if code != 200 {
|
||||
helper.ErrResponse(c, code)
|
||||
return
|
||||
}
|
||||
helper.ErrorWithDetail(c, constant.CodeErrDomain, constant.ErrTypeInternalServer, errors.New("domain not allowed"))
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"github.com/1Panel-dev/1Panel/backend/app/repo"
|
||||
)
|
||||
|
||||
func LoadErrCode(errInfo string) int {
|
||||
func LoadErrCode() int {
|
||||
settingRepo := repo.NewISettingRepo()
|
||||
codeVal, err := settingRepo.Get(settingRepo.WithByKey("NoAuthSetting"))
|
||||
if err != nil {
|
||||
|
@ -35,8 +35,9 @@ func WhiteAllow() gin.HandlerFunc {
|
||||
return
|
||||
}
|
||||
}
|
||||
if LoadErrCode("err-ip") != 200 {
|
||||
helper.ErrResponse(c, LoadErrCode("err-ip"))
|
||||
code := LoadErrCode()
|
||||
if code != 200 {
|
||||
helper.ErrResponse(c, code)
|
||||
return
|
||||
}
|
||||
helper.ErrorWithDetail(c, constant.CodeErrIP, constant.ErrTypeInternalServer, errors.New("IP address not allowed"))
|
||||
|
@ -132,12 +132,13 @@ class RequestHttp {
|
||||
);
|
||||
return;
|
||||
default:
|
||||
globalStore.isLogin = false;
|
||||
globalStore.errStatus = 'code-' + response.status;
|
||||
router.push({
|
||||
name: 'entrance',
|
||||
params: { code: globalStore.entrance },
|
||||
});
|
||||
return;
|
||||
return Promise.reject(error);
|
||||
}
|
||||
}
|
||||
if (!window.navigator.onLine) router.replace({ path: '/500' });
|
||||
|
@ -33,9 +33,3 @@ const loadErrInfo = () => {
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.container {
|
||||
margin-left: 40%;
|
||||
}
|
||||
</style>
|
||||
|
@ -1,7 +1,8 @@
|
||||
<template>
|
||||
<div>
|
||||
<div v-if="!loading">
|
||||
<div class="login-background" v-if="errStatus === ''">
|
||||
<div v-if="init">
|
||||
<div v-if="errStatus === ''">
|
||||
<div class="login-background">
|
||||
<div class="login-wrapper">
|
||||
<div :class="screenWidth > 1110 ? 'left inline-block' : ''">
|
||||
<div class="login-title">
|
||||
@ -16,6 +17,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else>
|
||||
<div v-if="errStatus === 'err-unsafe'">
|
||||
@ -46,14 +48,14 @@ import ErrIP from '@/components/error-message/err_ip.vue';
|
||||
import ErrCode from '@/components/error-message/error_code.vue';
|
||||
import ErrDomain from '@/components/error-message/err_domain.vue';
|
||||
import ErrFound from '@/components/error-message/404.vue';
|
||||
import { ref, onMounted, watch } from 'vue';
|
||||
import { ref, onMounted } from 'vue';
|
||||
import { GlobalStore } from '@/store';
|
||||
import { getXpackSettingForTheme } from '@/utils/xpack';
|
||||
const globalStore = GlobalStore();
|
||||
|
||||
const screenWidth = ref(null);
|
||||
const errStatus = ref('');
|
||||
const loading = ref();
|
||||
const errStatus = ref('x');
|
||||
const init = ref(false);
|
||||
|
||||
const mySafetyCode = defineProps({
|
||||
code: {
|
||||
@ -61,30 +63,25 @@ const mySafetyCode = defineProps({
|
||||
default: '',
|
||||
},
|
||||
});
|
||||
watch(
|
||||
() => globalStore.errStatus,
|
||||
(newVal) => {
|
||||
if (newVal?.startsWith('err-') || newVal?.startsWith('code-')) {
|
||||
errStatus.value = newVal;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
const getStatus = async () => {
|
||||
let code = mySafetyCode.code;
|
||||
globalStore.entrance = code;
|
||||
await checkIsSafety(code)
|
||||
.then(() => {
|
||||
let info = globalStore.errStatus;
|
||||
if (info?.startsWith('err-') || info?.startsWith('code-')) {
|
||||
errStatus.value = info;
|
||||
init.value = true;
|
||||
return;
|
||||
}
|
||||
let code = mySafetyCode.code;
|
||||
globalStore.entrance = code;
|
||||
loading.value = true;
|
||||
await checkIsSafety(code)
|
||||
.then(() => {
|
||||
loading.value = false;
|
||||
errStatus.value = '';
|
||||
init.value = true;
|
||||
getXpackSettingForTheme();
|
||||
})
|
||||
.catch(() => {
|
||||
loading.value = false;
|
||||
.catch((err) => {
|
||||
errStatus.value = 'code-' + err.status;
|
||||
init.value = true;
|
||||
});
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user