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