mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2026-11-17 16:06:18 +00:00
feat(auth): improve license agreement logic (#14410)
This commit is contained in:
+12
-11
@@ -236,17 +236,18 @@ func (b *BaseApi) GetLoginSetting(c *gin.Context) {
|
||||
ip := common.GetRealClientIP(c)
|
||||
needCaptcha := global.IPTracker.NeedCaptcha(ip)
|
||||
res := &dto.LoginSetting{
|
||||
IsDemo: global.CONF.Base.IsDemo,
|
||||
IsIntl: global.CONF.Base.Edition == "intl",
|
||||
IsOffline: global.CONF.Base.IsOffline,
|
||||
IsEnterprise: global.CONF.Base.IsEnterprise,
|
||||
Language: settingInfo.Language,
|
||||
MenuTabs: settingInfo.MenuTabs,
|
||||
MenuAccordion: settingInfo.MenuAccordion,
|
||||
PanelCache: settingInfo.PanelCache,
|
||||
PanelName: settingInfo.PanelName,
|
||||
Theme: settingInfo.Theme,
|
||||
NeedCaptcha: needCaptcha,
|
||||
IsDemo: global.CONF.Base.IsDemo,
|
||||
IsIntl: global.CONF.Base.Edition == "intl",
|
||||
IsOffline: global.CONF.Base.IsOffline,
|
||||
IsEnterprise: global.CONF.Base.IsEnterprise,
|
||||
IsMasterProductPro: xpack.IsMasterProductPro(),
|
||||
Language: settingInfo.Language,
|
||||
MenuTabs: settingInfo.MenuTabs,
|
||||
MenuAccordion: settingInfo.MenuAccordion,
|
||||
PanelCache: settingInfo.PanelCache,
|
||||
PanelName: settingInfo.PanelName,
|
||||
Theme: settingInfo.Theme,
|
||||
NeedCaptcha: needCaptcha,
|
||||
}
|
||||
res.PasskeySetting = xpack.AuthProvider.PasskeyStatus(c)
|
||||
helper.SuccessWithData(c, res)
|
||||
|
||||
+13
-12
@@ -293,18 +293,19 @@ type AppstoreConfig struct {
|
||||
}
|
||||
|
||||
type LoginSetting struct {
|
||||
IsDemo bool `json:"isDemo"`
|
||||
IsIntl bool `json:"isIntl"`
|
||||
IsOffline bool `json:"isOffline"`
|
||||
IsEnterprise bool `json:"isEnterprise"`
|
||||
Language string `json:"language"`
|
||||
MenuTabs string `json:"menuTabs"`
|
||||
MenuAccordion string `json:"menuAccordion"`
|
||||
PanelCache string `json:"panelCache"`
|
||||
PanelName string `json:"panelName"`
|
||||
Theme string `json:"theme"`
|
||||
NeedCaptcha bool `json:"needCaptcha"`
|
||||
PasskeySetting bool `json:"passkeySetting"`
|
||||
IsDemo bool `json:"isDemo"`
|
||||
IsIntl bool `json:"isIntl"`
|
||||
IsOffline bool `json:"isOffline"`
|
||||
IsEnterprise bool `json:"isEnterprise"`
|
||||
IsMasterProductPro bool `json:"isMasterProductPro"`
|
||||
Language string `json:"language"`
|
||||
MenuTabs string `json:"menuTabs"`
|
||||
MenuAccordion string `json:"menuAccordion"`
|
||||
PanelCache string `json:"panelCache"`
|
||||
PanelName string `json:"panelName"`
|
||||
Theme string `json:"theme"`
|
||||
NeedCaptcha bool `json:"needCaptcha"`
|
||||
PasskeySetting bool `json:"passkeySetting"`
|
||||
}
|
||||
|
||||
type PasskeyRegisterRequest struct {
|
||||
|
||||
@@ -11,6 +11,10 @@ var AuthProvider = helper.NewIAuthProvider()
|
||||
|
||||
var MultiNodeProvider = helper.NewIMultiNodeProvider()
|
||||
|
||||
func IsMasterProductPro() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func VMCountLimit(_ *gin.Context) int {
|
||||
return 1
|
||||
}
|
||||
|
||||
@@ -81,6 +81,7 @@ export namespace Login {
|
||||
theme: string;
|
||||
isOffline: boolean;
|
||||
isEnterprise: boolean;
|
||||
isMasterProductPro: boolean;
|
||||
needCaptcha: boolean;
|
||||
passkeySetting: boolean;
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@
|
||||
{{ $t('commons.login.passkeyToPassword') }}
|
||||
</el-link>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="!isIntl && !isEnterprise">
|
||||
<el-form-item v-if="!loginSettingsLoading && requireCommunityLicense">
|
||||
<el-checkbox v-model="loginForm.agreeLicense">
|
||||
<template #default>
|
||||
<span class="agree-title">
|
||||
@@ -256,6 +256,7 @@
|
||||
class="w-full login-button"
|
||||
type="primary"
|
||||
size="default"
|
||||
:disabled="loginSettingsLoading"
|
||||
>
|
||||
{{ $t('commons.button.login') }}
|
||||
</el-button>
|
||||
@@ -312,7 +313,7 @@
|
||||
<el-text v-if="isDemo" type="danger" class="demo">
|
||||
{{ $t('commons.login.username') }}:demo {{ $t('commons.login.password') }}:1panel
|
||||
</el-text>
|
||||
<el-form-item prop="agreeLicense" v-if="!isIntl && !isEnterprise">
|
||||
<el-form-item prop="agreeLicense" v-if="!loginSettingsLoading && requireCommunityLicense">
|
||||
<el-checkbox v-model="loginForm.agreeLicense">
|
||||
<template #default>
|
||||
<span class="agree-title">
|
||||
@@ -430,6 +431,9 @@ const autoPasskeyEnabledKey = '1panel-passkey-auto-enabled';
|
||||
const showPasswordLogin = ref(false);
|
||||
const loginSource = ref<'local' | 'ldap'>('local');
|
||||
const isDemo = ref(false);
|
||||
const loginSettingsLoading = ref(true);
|
||||
const isMasterProductPro = ref(false);
|
||||
const requireCommunityLicense = computed(() => !isIntl.value && !isEnterprise.value && !isMasterProductPro.value);
|
||||
const open = ref(false);
|
||||
const loginBtnLinkColor = ref<string | null>(null);
|
||||
let loginViewActive = true;
|
||||
@@ -476,7 +480,7 @@ function checkPassword(rule: any, value: any, callback: any) {
|
||||
callback();
|
||||
}
|
||||
function checkAgreeLicense(rule: any, value: any, callback: any) {
|
||||
if (!value && !_isMobile()) {
|
||||
if (requireCommunityLicense.value && !value && !_isMobile()) {
|
||||
return callback(new Error(i18n.t('commons.login.errorAgree')));
|
||||
}
|
||||
callback();
|
||||
@@ -627,12 +631,12 @@ const handleLoginResult = async (result: LoginModel.ResLogin) => {
|
||||
};
|
||||
|
||||
const login = (formEl: FormInstance | undefined) => {
|
||||
if (!formEl || isLoggingIn) return;
|
||||
if (!formEl || isLoggingIn || loginSettingsLoading.value) return;
|
||||
errAuthInfo.value = false;
|
||||
errCaptcha.value = false;
|
||||
formEl.validate(async (valid) => {
|
||||
if (!valid) return;
|
||||
if (isIntl.value || isEnterprise.value) {
|
||||
if (!requireCommunityLicense.value) {
|
||||
loginForm.agreeLicense = true;
|
||||
}
|
||||
if (!loginForm.agreeLicense) {
|
||||
@@ -728,7 +732,7 @@ const passkeyLogin = async () => {
|
||||
MsgError(i18n.t('commons.login.passkeyNotSupported'));
|
||||
return;
|
||||
}
|
||||
if (!isIntl.value && !isEnterprise.value && !loginForm.agreeLicense) {
|
||||
if (requireCommunityLicense.value && !loginForm.agreeLicense) {
|
||||
if (_isMobile() || showPasskeyOnly.value) {
|
||||
pendingLoginMethod.value = 'passkey';
|
||||
open.value = true;
|
||||
@@ -916,6 +920,7 @@ const getSetting = async () => {
|
||||
isIntl.value = res.data.isIntl;
|
||||
isOffline.value = res.data.isOffline;
|
||||
isEnterprise.value = res.data.isEnterprise;
|
||||
isMasterProductPro.value = Boolean(res.data.isMasterProductPro);
|
||||
isEnterpriseLicenseLoaded.value = !res.data.isEnterprise;
|
||||
ignoreCaptcha.value = !res.data.needCaptcha;
|
||||
passkeySetting.value = res.data.passkeySetting;
|
||||
@@ -936,7 +941,10 @@ const getSetting = async () => {
|
||||
if (passkeySetting.value && passkeySupported.value && isAutoPasskeyEnabled() && !hasPendingExternalTicket) {
|
||||
passkeyLogin();
|
||||
}
|
||||
} catch (error) {}
|
||||
} catch (error) {
|
||||
} finally {
|
||||
loginSettingsLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const applyLoginButtonTheme = () => {
|
||||
|
||||
Reference in New Issue
Block a user