mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-31 14:08:06 +08:00
fix: 修改数据库创建权限校验规则 (#2220)
This commit is contained in:
parent
f812d9f7cd
commit
6e8f22a4a6
@ -14,7 +14,6 @@ import (
|
||||
"github.com/1Panel-dev/1Panel/backend/buserr"
|
||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
||||
"github.com/1Panel-dev/1Panel/backend/global"
|
||||
"github.com/1Panel-dev/1Panel/backend/utils/common"
|
||||
"github.com/1Panel-dev/1Panel/backend/utils/files"
|
||||
)
|
||||
|
||||
@ -307,12 +306,13 @@ func (r *Local) SyncDB(version string) ([]SyncDBInfo, error) {
|
||||
}
|
||||
if len(dataItem.Username) == 0 {
|
||||
dataItem.Username = loadNameByDB(parts[0], version)
|
||||
dataItem.Password = randomPassword(dataItem.Username)
|
||||
if err := r.CreateUser(CreateInfo{
|
||||
Name: parts[0],
|
||||
Format: parts[1],
|
||||
Version: version,
|
||||
Username: dataItem.Username,
|
||||
Password: common.RandStr(16),
|
||||
Password: dataItem.Password,
|
||||
Permission: "%",
|
||||
Timeout: 300,
|
||||
}, false); err != nil {
|
||||
|
@ -12,7 +12,6 @@ import (
|
||||
"github.com/1Panel-dev/1Panel/backend/buserr"
|
||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
||||
"github.com/1Panel-dev/1Panel/backend/global"
|
||||
"github.com/1Panel-dev/1Panel/backend/utils/common"
|
||||
"github.com/1Panel-dev/1Panel/backend/utils/files"
|
||||
"github.com/1Panel-dev/1Panel/backend/utils/mysql/helper"
|
||||
)
|
||||
@ -317,7 +316,7 @@ func (r *Remote) SyncDB(version string) ([]SyncDBInfo, error) {
|
||||
}
|
||||
if len(dataItem.Username) == 0 {
|
||||
dataItem.Username = loadNameByDB(dbName, version)
|
||||
dataItem.Password = common.RandStr(16)
|
||||
dataItem.Password = randomPassword(dataItem.Username)
|
||||
if err := r.CreateUser(CreateInfo{
|
||||
Name: dbName,
|
||||
Format: charsetName,
|
||||
@ -329,7 +328,6 @@ func (r *Remote) SyncDB(version string) ([]SyncDBInfo, error) {
|
||||
}, false); err != nil {
|
||||
return datas, fmt.Errorf("sync db from remote server failed, err: create user failed %v", err)
|
||||
}
|
||||
|
||||
dataItem.Permission = "%"
|
||||
} else {
|
||||
if isLocal {
|
||||
|
@ -84,7 +84,7 @@ import { ElForm } from 'element-plus';
|
||||
import { addMysqlDB } from '@/api/modules/database';
|
||||
import DrawerHeader from '@/components/drawer-header/index.vue';
|
||||
import { MsgSuccess } from '@/utils/message';
|
||||
import { getRandomStr } from '@/utils/util';
|
||||
import { checkIp, getRandomStr } from '@/utils/util';
|
||||
|
||||
const loading = ref();
|
||||
const createVisiable = ref(false);
|
||||
@ -105,8 +105,18 @@ const rules = reactive({
|
||||
username: [Rules.requiredInput, Rules.name],
|
||||
password: [Rules.paramComplexity],
|
||||
permission: [Rules.requiredSelect],
|
||||
permissionIPs: [Rules.requiredInput],
|
||||
permissionIPs: [{ validator: checkIPs, trigger: 'blur', required: true }],
|
||||
});
|
||||
function checkIPs(rule: any, value: any, callback: any) {
|
||||
let ips = form.permissionIPs.split(',');
|
||||
for (const item of ips) {
|
||||
if (checkIp(item)) {
|
||||
return callback(new Error(i18n.global.t('commons.rule.ip')));
|
||||
}
|
||||
}
|
||||
callback();
|
||||
}
|
||||
|
||||
type FormInstance = InstanceType<typeof ElForm>;
|
||||
const formRef = ref<FormInstance>();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user