mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-11-24 02:59:16 +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,17 +1,19 @@
|
||||
<template>
|
||||
<div>
|
||||
<div v-if="!loading">
|
||||
<div class="login-background" v-if="errStatus === ''">
|
||||
<div class="login-wrapper">
|
||||
<div :class="screenWidth > 1110 ? 'left inline-block' : ''">
|
||||
<div class="login-title">
|
||||
<span>{{ globalStore.themeConfig.title || $t('setting.description') }}</span>
|
||||
<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">
|
||||
<span>{{ globalStore.themeConfig.title || $t('setting.description') }}</span>
|
||||
</div>
|
||||
<img src="@/assets/images/1panel-login.png" alt="" v-if="screenWidth > 1110" />
|
||||
</div>
|
||||
<img src="@/assets/images/1panel-login.png" alt="" v-if="screenWidth > 1110" />
|
||||
</div>
|
||||
<div :class="screenWidth > 1110 ? 'right inline-block' : ''">
|
||||
<div class="login-container">
|
||||
<LoginForm ref="loginRef"></LoginForm>
|
||||
<div :class="screenWidth > 1110 ? 'right inline-block' : ''">
|
||||
<div class="login-container">
|
||||
<LoginForm ref="loginRef"></LoginForm>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -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 info = globalStore.errStatus;
|
||||
if (info?.startsWith('err-') || info?.startsWith('code-')) {
|
||||
errStatus.value = info;
|
||||
return;
|
||||
}
|
||||
let code = mySafetyCode.code;
|
||||
globalStore.entrance = code;
|
||||
loading.value = true;
|
||||
await checkIsSafety(code)
|
||||
.then(() => {
|
||||
loading.value = false;
|
||||
let info = globalStore.errStatus;
|
||||
if (info?.startsWith('err-') || info?.startsWith('code-')) {
|
||||
errStatus.value = info;
|
||||
init.value = true;
|
||||
return;
|
||||
}
|
||||
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