Skip to content

Commit 170bd22

Browse files
authored
fix: Modify database verification rules (#8342)
1 parent 097a33c commit 170bd22

5 files changed

Lines changed: 22 additions & 35 deletions

File tree

backend/app/service/cronjob.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ func (u *CronjobService) CleanRecord(req dto.CronjobClean) error {
122122
}
123123
}
124124
cronjob.RetainCopies = 0
125-
u.removeExpiredBackup(cronjob, accountMap, model.BackupRecord{})
125+
if len(accountMap) != 0 {
126+
u.removeExpiredBackup(cronjob, accountMap, model.BackupRecord{})
127+
}
126128
} else {
127129
u.removeExpiredLog(cronjob)
128130
}

frontend/src/views/database/mysql/bind/index.vue

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,21 @@
1818
</el-form-item>
1919
<el-form-item :label="$t('commons.login.password')" prop="password">
2020
<el-input type="password" clearable show-password v-model="form.password"></el-input>
21+
<span class="input-help">{{ $t('commons.rule.illegalChar') }}</span>
2122
</el-form-item>
2223
<el-form-item :label="$t('database.permission')" prop="permission">
2324
<el-select v-model="form.permission">
2425
<el-option value="%" :label="$t('database.permissionAll')" />
2526
<el-option
2627
v-if="form.from !== 'local'"
2728
value="localhost"
28-
:label="$t('terminal.localhost')"
29+
:label="$t('terminal.localhost') + '(localhost)'"
2930
/>
3031
<el-option value="ip" :label="$t('database.permissionForIP')" />
3132
</el-select>
33+
<span v-if="form.from !== 'local'" class="input-help">
34+
{{ $t('database.localhostHelper') }}
35+
</span>
3236
</el-form-item>
3337
<el-form-item v-if="form.permission === 'ip'" prop="permissionIPs">
3438
<el-input clearable :rows="3" type="textarea" v-model="form.permissionIPs" />
@@ -60,7 +64,6 @@ import { bindUser } from '@/api/modules/database';
6064
import DrawerHeader from '@/components/drawer-header/index.vue';
6165
import { Rules } from '@/global/form-rules';
6266
import { MsgSuccess } from '@/utils/message';
63-
import { checkIp } from '@/utils/util';
6467
6568
const loading = ref();
6669
const bindVisible = ref(false);
@@ -79,21 +82,11 @@ const confirmDialogRef = ref();
7982
8083
const rules = reactive({
8184
username: [Rules.requiredInput, Rules.name],
82-
password: [Rules.paramComplexity],
85+
password: [Rules.requiredInput, Rules.noSpace, Rules.illegal],
8386
permission: [Rules.requiredSelect],
84-
permissionIPs: [{ validator: checkIPs, trigger: 'blur', required: true }],
87+
permissionIPs: [Rules.requiredInput, Rules.noSpace, Rules.illegal],
8588
});
8689
87-
function checkIPs(rule: any, value: any, callback: any) {
88-
let ips = form.permissionIPs.split(',');
89-
for (const item of ips) {
90-
if (checkIp(item)) {
91-
return callback(new Error(i18n.global.t('commons.rule.ip')));
92-
}
93-
}
94-
callback();
95-
}
96-
9790
interface DialogProps {
9891
from: string;
9992
database: string;

frontend/src/views/database/mysql/create/index.vue

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,13 @@
4343
<el-option
4444
v-if="form.from !== 'local'"
4545
value="localhost"
46-
:label="$t('terminal.localhost')"
46+
:label="$t('terminal.localhost') + '(localhost)'"
4747
/>
4848
<el-option value="ip" :label="$t('database.permissionForIP')" />
4949
</el-select>
50+
<span v-if="form.from !== 'local'" class="input-help">
51+
{{ $t('database.localhostHelper') }}
52+
</span>
5053
</el-form-item>
5154
<el-form-item v-if="form.permission === 'ip'" prop="permissionIPs">
5255
<el-input clearable :rows="3" type="textarea" v-model="form.permissionIPs" />
@@ -86,7 +89,7 @@ import { ElForm } from 'element-plus';
8689
import { addMysqlDB } from '@/api/modules/database';
8790
import DrawerHeader from '@/components/drawer-header/index.vue';
8891
import { MsgSuccess } from '@/utils/message';
89-
import { checkIp, getRandomStr } from '@/utils/util';
92+
import { getRandomStr } from '@/utils/util';
9093
9194
const loading = ref();
9295
const createVisible = ref(false);
@@ -107,17 +110,8 @@ const rules = reactive({
107110
username: [Rules.requiredInput, Rules.name],
108111
password: [Rules.requiredInput, Rules.noSpace, Rules.illegal],
109112
permission: [Rules.requiredSelect],
110-
permissionIPs: [{ validator: checkIPs, trigger: 'blur', required: true }],
113+
permissionIPs: [Rules.requiredInput, Rules.noSpace, Rules.illegal],
111114
});
112-
function checkIPs(rule: any, value: any, callback: any) {
113-
let ips = form.permissionIPs.split(',');
114-
for (const item of ips) {
115-
if (checkIp(item)) {
116-
return callback(new Error(i18n.global.t('commons.rule.ip')));
117-
}
118-
}
119-
callback();
120-
}
121115
122116
type FormInstance = InstanceType<typeof ElForm>;
123117
const formRef = ref<FormInstance>();

frontend/src/views/database/mysql/password/index.vue

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,7 @@
1818
<el-input disabled v-model="changeForm.userName"></el-input>
1919
</el-form-item>
2020
<el-form-item :label="$t('commons.login.password')" prop="password">
21-
<el-input
22-
type="password"
23-
clearable
24-
show-password
25-
v-model="changeForm.password"
26-
></el-input>
21+
<el-input type="password" clearable show-password v-model="changeForm.password" />
2722
<span class="input-help">{{ $t('commons.rule.illegalChar') }}</span>
2823
</el-form-item>
2924
</div>
@@ -38,7 +33,9 @@
3833
/>
3934
<el-option value="ip" :label="$t('database.permissionForIP')" />
4035
</el-select>
41-
<span class="input-help">{{ $t('database.localhostHelper') }}</span>
36+
<span v-if="changeForm.from !== 'local'" class="input-help">
37+
{{ $t('database.localhostHelper') }}
38+
</span>
4239
</el-form-item>
4340
<el-form-item v-if="changeForm.privilege === 'ip'" prop="privilegeIPs">
4441
<el-input clearable :rows="3" type="textarea" v-model="changeForm.privilegeIPs" />

frontend/src/views/database/postgresql/bind/index.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
</el-form-item>
2020
<el-form-item :label="$t('commons.login.password')" prop="password">
2121
<el-input type="password" clearable show-password v-model="form.password" />
22+
<span class="input-help">{{ $t('commons.rule.illegalChar') }}</span>
2223
</el-form-item>
2324
<el-form-item :label="$t('database.permission')" prop="superUser">
2425
<el-checkbox v-model="form.superUser">{{ $t('database.pgSuperUser') }}</el-checkbox>
@@ -65,7 +66,7 @@ const confirmDialogRef = ref();
6566
6667
const rules = reactive({
6768
username: [Rules.requiredInput, Rules.name],
68-
password: [Rules.paramComplexity],
69+
password: [Rules.requiredInput, Rules.noSpace, Rules.illegal],
6970
});
7071
7172
interface DialogProps {

0 commit comments

Comments
 (0)