mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-02-07 17:10:07 +08:00
fix: Redis 数据库连接信息移除密码限制 (#5239)
This commit is contained in:
parent
8c929004e9
commit
400dd79b9f
@ -166,7 +166,7 @@ type MysqlVariablesUpdateHelper struct {
|
|||||||
// redis
|
// redis
|
||||||
type ChangeRedisPass struct {
|
type ChangeRedisPass struct {
|
||||||
Database string `json:"database" validate:"required"`
|
Database string `json:"database" validate:"required"`
|
||||||
Value string `json:"value" validate:"required"`
|
Value string `json:"value"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type RedisConfUpdate struct {
|
type RedisConfUpdate struct {
|
||||||
|
@ -154,9 +154,15 @@ func (u *CommandService) ListRedisCommand() ([]dto.RedisCommand, error) {
|
|||||||
return dtoCommands, err
|
return dtoCommands, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *CommandService) SaveRedisCommand(commandDto dto.RedisCommand) error {
|
func (u *CommandService) SaveRedisCommand(req dto.RedisCommand) error {
|
||||||
|
if req.ID == 0 {
|
||||||
|
command, _ := commandRepo.GetRedis(commonRepo.WithByName(req.Name))
|
||||||
|
if command.ID != 0 {
|
||||||
|
return constant.ErrRecordExist
|
||||||
|
}
|
||||||
|
}
|
||||||
var command model.RedisCommand
|
var command model.RedisCommand
|
||||||
if err := copier.Copy(&command, &commandDto); err != nil {
|
if err := copier.Copy(&command, &req); err != nil {
|
||||||
return errors.WithMessage(constant.ErrStructTransform, err.Error())
|
return errors.WithMessage(constant.ErrStructTransform, err.Error())
|
||||||
}
|
}
|
||||||
if err := commandRepo.SaveRedis(&command); err != nil {
|
if err := commandRepo.SaveRedis(&command); err != nil {
|
||||||
|
@ -19,13 +19,13 @@
|
|||||||
</el-button>
|
</el-button>
|
||||||
<el-table :data="data" class="mt-5" @selection-change="handleSelectionChange">
|
<el-table :data="data" class="mt-5" @selection-change="handleSelectionChange">
|
||||||
<el-table-column type="selection" fix />
|
<el-table-column type="selection" fix />
|
||||||
<el-table-column :label="$t('commons.table.name')" min-width="50">
|
<el-table-column :label="$t('commons.table.name')" min-width="50" show-overflow-tooltip>
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-input v-if="row.lineStatus === 'create' || row.lineStatus === 'edit'" v-model="row.name" />
|
<el-input v-if="row.lineStatus === 'create' || row.lineStatus === 'edit'" v-model="row.name" />
|
||||||
<span v-else>{{ row.name }}</span>
|
<span v-else>{{ row.name }}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column :label="$t('terminal.quickCommand')" min-width="120">
|
<el-table-column :label="$t('terminal.quickCommand')" min-width="120" show-overflow-tooltip>
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-input
|
<el-input
|
||||||
v-if="row.lineStatus === 'create' || row.lineStatus === 'edit'"
|
v-if="row.lineStatus === 'create' || row.lineStatus === 'edit'"
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<template #header>
|
<template #header>
|
||||||
<DrawerHeader :header="$t('database.databaseConnInfo')" :back="handleClose" />
|
<DrawerHeader :header="$t('database.databaseConnInfo')" :back="handleClose" />
|
||||||
</template>
|
</template>
|
||||||
<el-form @submit.prevent v-loading="loading" ref="formRef" :model="form" label-position="top">
|
<el-form @submit.prevent v-loading="loading" ref="formRef" :model="form" label-position="top" :rules="rules">
|
||||||
<el-row type="flex" justify="center">
|
<el-row type="flex" justify="center">
|
||||||
<el-col :span="22">
|
<el-col :span="22">
|
||||||
<el-form-item :label="$t('database.containerConn')" v-if="form.from === 'local'">
|
<el-form-item :label="$t('database.containerConn')" v-if="form.from === 'local'">
|
||||||
@ -66,12 +66,7 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-divider border-style="dashed" />
|
<el-divider border-style="dashed" />
|
||||||
<el-form-item
|
<el-form-item :label="$t('commons.login.password')" v-if="form.from === 'local'" prop="password">
|
||||||
:label="$t('commons.login.password')"
|
|
||||||
v-if="form.from === 'local'"
|
|
||||||
:rules="Rules.paramComplexity"
|
|
||||||
prop="password"
|
|
||||||
>
|
|
||||||
<el-input type="password" show-password clearable v-model="form.password">
|
<el-input type="password" show-password clearable v-model="form.password">
|
||||||
<template #append>
|
<template #append>
|
||||||
<CopyButton :content="form.password" />
|
<CopyButton :content="form.password" />
|
||||||
@ -109,7 +104,6 @@
|
|||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { reactive, ref } from 'vue';
|
import { reactive, ref } from 'vue';
|
||||||
import { Rules } from '@/global/form-rules';
|
|
||||||
import i18n from '@/lang';
|
import i18n from '@/lang';
|
||||||
import { ElForm } from 'element-plus';
|
import { ElForm } from 'element-plus';
|
||||||
import { changeRedisPassword, getDatabase } from '@/api/modules/database';
|
import { changeRedisPassword, getDatabase } from '@/api/modules/database';
|
||||||
@ -135,6 +129,21 @@ const form = reactive({
|
|||||||
database: '',
|
database: '',
|
||||||
remoteIP: '',
|
remoteIP: '',
|
||||||
});
|
});
|
||||||
|
const rules = reactive({
|
||||||
|
password: [{ validator: checkPassword, trigger: 'blur' }],
|
||||||
|
});
|
||||||
|
|
||||||
|
function checkPassword(rule: any, value: any, callback: any) {
|
||||||
|
if (form.password !== '') {
|
||||||
|
const reg = /^[a-zA-Z0-9]{1}[a-zA-Z0-9.%@!~_-]{4,126}[a-zA-Z0-9]{1}$/;
|
||||||
|
if (!reg.test(value) && value !== '') {
|
||||||
|
callback(new Error(i18n.global.t('commons.rule.paramComplexity', ['.%@!~_-'])));
|
||||||
|
} else {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
|
||||||
const confirmDialogRef = ref();
|
const confirmDialogRef = ref();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user