mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-11-24 11:09:16 +08:00
fix: 修改部分表单校验方法 (#3217)
This commit is contained in:
parent
b8d3ab4f61
commit
bd2003c1b6
@ -120,7 +120,7 @@ func (u *Fail2BanService) UpdateConf(req dto.Fail2BanUpdate) error {
|
||||
newFile += fmt.Sprintf("%s = %s\n", req.Key, req.Value)
|
||||
continue
|
||||
}
|
||||
if strings.HasPrefix(line, "[") || index != len(lines)-1 {
|
||||
if strings.HasPrefix(line, "[") || index == len(lines)-1 {
|
||||
isEnd = true
|
||||
if !hasKey {
|
||||
newFile += fmt.Sprintf("%s = %s\n", req.Key, req.Value)
|
||||
|
@ -51,7 +51,7 @@ func (u *LogService) ListSystemLogFile() ([]string, error) {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !info.IsDir() && strings.HasPrefix(info.Name(), "1Panel-") {
|
||||
if !info.IsDir() && strings.HasPrefix(info.Name(), "1Panel") {
|
||||
if info.Name() == "1Panel.log" {
|
||||
files = append(files, time.Now().Format("2006-01-02"))
|
||||
return nil
|
||||
|
@ -107,7 +107,10 @@ func (u *SettingService) Update(key, value string) error {
|
||||
|
||||
switch key {
|
||||
case "ExpirationDays":
|
||||
timeout, _ := strconv.Atoi(value)
|
||||
timeout, err := strconv.Atoi(value)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := settingRepo.Update("ExpirationTime", time.Now().AddDate(0, 0, timeout).Format("2006-01-02 15:04:05")); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -150,6 +153,7 @@ func (u *SettingService) UpdateBindInfo(req dto.BindInfo) error {
|
||||
return err
|
||||
}
|
||||
go func() {
|
||||
time.Sleep(1 * time.Second)
|
||||
_, err := cmd.Exec("systemctl restart 1panel.service")
|
||||
if err != nil {
|
||||
global.LOG.Errorf("restart system with new bind info failed, err: %v", err)
|
||||
|
@ -29,9 +29,9 @@ func NewFail2Ban() (*Fail2ban, error) {
|
||||
if err := initLocalFile(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
stdout, err := cmd.Exec("fail2ban-client reload")
|
||||
stdout, err := cmd.Exec("systemctl restart fail2ban.service")
|
||||
if err != nil {
|
||||
global.LOG.Errorf("reload fail2ban failed, err: %s", stdout)
|
||||
global.LOG.Errorf("restart fail2ban failed, err: %s", stdout)
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ const checkUserName = (rule: any, value: any, callback: any) => {
|
||||
if (value === '' || typeof value === 'undefined' || value == null) {
|
||||
callback(new Error(i18n.global.t('commons.rule.userName')));
|
||||
} else {
|
||||
const reg = /[a-zA-Z0-9_\u4e00-\u9fa5]{3,30}$/;
|
||||
const reg = /^[a-zA-Z0-9_\u4e00-\u9fa5]{3,30}$/;
|
||||
if (!reg.test(value) && value !== '') {
|
||||
callback(new Error(i18n.global.t('commons.rule.userName')));
|
||||
} else {
|
||||
@ -158,7 +158,7 @@ const checkSimpleName = (rule: any, value: any, callback: any) => {
|
||||
if (value === '' || typeof value === 'undefined' || value == null) {
|
||||
callback(new Error(i18n.global.t('commons.rule.simpleName')));
|
||||
} else {
|
||||
const reg = /^[a-zA-Z0-9]{1}[a-zA-Z0-9_]{1,29}$/;
|
||||
const reg = /^[a-zA-Z0-9]{1}[a-zA-Z0-9_]{2,29}$/;
|
||||
if (!reg.test(value) && value !== '') {
|
||||
callback(new Error(i18n.global.t('commons.rule.simpleName')));
|
||||
} else {
|
||||
|
@ -158,12 +158,12 @@ const message = {
|
||||
illegalInput: 'There are illegal characters in the input box.',
|
||||
commonName: 'Support English, Chinese, numbers, .-, and _ length 1-128',
|
||||
userName: 'Support English, Chinese, numbers and _ length 3-30',
|
||||
simpleName: 'Support English, numbers and _ length 1-30',
|
||||
simpleName: 'Supports non-underscore starting, English, numbers, _, length 1-30',
|
||||
dbName: 'Support English, Chinese, numbers, .-, and _ length 1-64',
|
||||
imageName: 'Support English, numbers, :/.-_, length 1-150',
|
||||
volumeName: 'Support English, numbers, .-_, length 2-30',
|
||||
complexityPassword:
|
||||
'Longer than eight characters and contains at least two combinations of letters, digits, and special characters',
|
||||
'Please enter a password combination with a length of 8-30 characters, including letters, numbers, and at least two special characters.',
|
||||
commonPassword: 'Please enter a password with more than 6 characters',
|
||||
linuxName: 'Length 1-128, the name cannot contain symbols such as {0}',
|
||||
email: 'Email format error',
|
||||
@ -1277,8 +1277,7 @@ const message = {
|
||||
'[ {0} days ] The panel password is about to expire. After the expiration, you need to reset the password',
|
||||
complexity: 'Complexity Verification',
|
||||
complexityHelper:
|
||||
'The password must contain at least eight characters and contain at least three uppercase letters, lowercase letters, digits, and special characters',
|
||||
|
||||
'After enabling, the password must have a length of 8-30 characters, including letters, numbers, and at least two special characters.',
|
||||
bindDomain: 'Bind Domain',
|
||||
unBindDomain: 'Unbind domain',
|
||||
panelSSL: 'Panel SSL',
|
||||
|
@ -159,11 +159,11 @@ const message = {
|
||||
illegalInput: '輸入框中存在不合法字符',
|
||||
commonName: '支持英文、中文、數字、.-和_,長度1-128',
|
||||
userName: '支持英文、中文、數字和_,長度3-30',
|
||||
simpleName: '支持英文、數字、_,長度1-30',
|
||||
simpleName: '支持非底線開頭,英文、數字、_,長度1-30',
|
||||
dbName: '支持英文、中文、數字、.-_,長度1-64',
|
||||
imageName: '支持英文、數字、:/.-_,長度1-150',
|
||||
volumeName: '支持英文、數字、.-和_,長度2-30',
|
||||
complexityPassword: '請輸入長度大於 8 位且包含字母、數字、特殊字符至少兩項的密碼組合',
|
||||
complexityPassword: '請輸入長度為 8-30 位,並包含字母、數字、至少兩種特殊字符的密碼組合',
|
||||
commonPassword: '請輸入 6 位以上長度密碼',
|
||||
linuxName: '長度1-128,名稱不能含有{0}等符號',
|
||||
email: '請輸入正確的郵箱',
|
||||
@ -1240,7 +1240,7 @@ const message = {
|
||||
expiredHelper: '當前密碼已過期,請重新修改密碼:',
|
||||
timeoutHelper: '【 {0} 天後 】面板密碼即將過期,過期後需要重新設置密碼',
|
||||
complexity: '密碼復雜度驗證',
|
||||
complexityHelper: '開啟後密碼必須滿足密碼長度大於 8 位且包含字母、數字及特殊字符',
|
||||
complexityHelper: '開啟後密碼必須滿足長度為 8-30 位,並包含字母、數字、至少兩種特殊字符',
|
||||
bindDomain: '域名綁定',
|
||||
unBindDomain: '域名解綁',
|
||||
panelSSL: '面板 SSL',
|
||||
|
@ -159,11 +159,11 @@ const message = {
|
||||
illegalInput: '输入框中存在不合法字符',
|
||||
commonName: '支持英文、中文、数字、.-和_,长度1-128',
|
||||
userName: '支持英文、中文、数字和_,长度3-30',
|
||||
simpleName: '支持英文、数字、_,长度1-30',
|
||||
simpleName: '支持非下划线开头,英文、数字、_,长度3-30',
|
||||
dbName: '支持英文、中文、数字、.-_,长度1-64',
|
||||
imageName: '支持英文、数字、:/.-_,长度1-150',
|
||||
volumeName: '支持英文、数字、.-和_,长度2-30',
|
||||
complexityPassword: '请输入长度大于 8 位且包含字母、数字、特殊字符至少两项的密码组合',
|
||||
complexityPassword: '请输入长度为 8-30 位且包含字母、数字、特殊字符至少两项的密码组合',
|
||||
commonPassword: '请输入 6 位以上长度密码',
|
||||
linuxName: '长度1-128,名称不能含有{0}等符号',
|
||||
email: '请输入正确的邮箱',
|
||||
@ -1241,7 +1241,7 @@ const message = {
|
||||
expiredHelper: '当前密码已过期,请重新修改密码:',
|
||||
timeoutHelper: '【 {0} 天后 】面板密码即将过期,过期后需要重新设置密码',
|
||||
complexity: '密码复杂度验证',
|
||||
complexityHelper: '开启后密码必须满足密码长度大于 8 位且包含字母、数字及特殊字符',
|
||||
complexityHelper: '开启后密码必须满足长度为 8-30 位且包含字母、数字、特殊字符至少两项',
|
||||
bindDomain: '域名绑定',
|
||||
unBindDomain: '域名解绑',
|
||||
panelSSL: '面板 SSL',
|
||||
|
@ -10,7 +10,7 @@
|
||||
<el-form-item
|
||||
:label="$t('setting.days')"
|
||||
prop="days"
|
||||
:rules="[Rules.number, checkNumberRange(0, 60)]"
|
||||
:rules="[Rules.integerNumberWith0, checkNumberRange(0, 60)]"
|
||||
>
|
||||
<el-input clearable v-model.number="form.days" />
|
||||
<span class="input-help">{{ $t('setting.expirationHelper') }}</span>
|
||||
|
@ -7,7 +7,11 @@
|
||||
<el-form ref="formRef" label-position="top" :model="form" @submit.prevent v-loading="loading">
|
||||
<el-row type="flex" justify="center">
|
||||
<el-col :span="22">
|
||||
<el-form-item :label="$t('toolbox.fail2ban.banTime')" prop="banTime" :rules="Rules.number">
|
||||
<el-form-item
|
||||
:label="$t('toolbox.fail2ban.banTime')"
|
||||
prop="banTime"
|
||||
:rules="Rules.integerNumber"
|
||||
>
|
||||
<el-input type="number" v-model.number="form.banTime">
|
||||
<template #append>
|
||||
<el-select v-model.number="form.banTimeUnit" style="width: 100px">
|
||||
|
@ -10,7 +10,7 @@
|
||||
<el-form-item
|
||||
:label="$t('toolbox.fail2ban.findTime')"
|
||||
prop="findTime"
|
||||
:rules="Rules.requiredInput"
|
||||
:rules="Rules.integerNumber"
|
||||
>
|
||||
<el-input clearable v-model.number="form.findTime">
|
||||
<template #append>
|
||||
|
@ -55,7 +55,7 @@ const form = reactive({
|
||||
});
|
||||
|
||||
const rules = reactive({
|
||||
maxRetry: [Rules.number, checkNumberRange(1, 99)],
|
||||
maxRetry: [Rules.integerNumber, checkNumberRange(1, 99)],
|
||||
});
|
||||
|
||||
const formRef = ref<FormInstance>();
|
||||
|
Loading…
Reference in New Issue
Block a user