mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-12-10 04:16:29 +08:00
fix: 解决 redis 修改密码报错的问题 (#2271)
This commit is contained in:
parent
47cfa0c730
commit
6f250e63db
8 changed files with 45 additions and 20 deletions
|
|
@ -92,13 +92,13 @@ func (b *BaseApi) UpdateRedisConf(c *gin.Context) {
|
||||||
// @Summary Change redis password
|
// @Summary Change redis password
|
||||||
// @Description 更新 redis 密码
|
// @Description 更新 redis 密码
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.ChangeDBInfo true "request"
|
// @Param request body dto.ChangeRedisPass true "request"
|
||||||
// @Success 200
|
// @Success 200
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Router /databases/redis/password [post]
|
// @Router /databases/redis/password [post]
|
||||||
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFuntions":[],"formatZH":"修改 redis 数据库密码","formatEN":"change the password of the redis database"}
|
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFuntions":[],"formatZH":"修改 redis 数据库密码","formatEN":"change the password of the redis database"}
|
||||||
func (b *BaseApi) ChangeRedisPassword(c *gin.Context) {
|
func (b *BaseApi) ChangeRedisPassword(c *gin.Context) {
|
||||||
var req dto.ChangeDBInfo
|
var req dto.ChangeRedisPass
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -172,6 +172,10 @@ type UploadRecover struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// redis
|
// redis
|
||||||
|
type ChangeRedisPass struct {
|
||||||
|
Value string `json:"value" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
type RedisConfUpdate struct {
|
type RedisConfUpdate struct {
|
||||||
Timeout string `json:"timeout"`
|
Timeout string `json:"timeout"`
|
||||||
Maxclients string `json:"maxclients"`
|
Maxclients string `json:"maxclients"`
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ type RedisService struct{}
|
||||||
type IRedisService interface {
|
type IRedisService interface {
|
||||||
UpdateConf(req dto.RedisConfUpdate) error
|
UpdateConf(req dto.RedisConfUpdate) error
|
||||||
UpdatePersistenceConf(req dto.RedisConfPersistenceUpdate) error
|
UpdatePersistenceConf(req dto.RedisConfPersistenceUpdate) error
|
||||||
ChangePassword(info dto.ChangeDBInfo) error
|
ChangePassword(info dto.ChangeRedisPass) error
|
||||||
|
|
||||||
LoadStatus() (*dto.RedisStatus, error)
|
LoadStatus() (*dto.RedisStatus, error)
|
||||||
LoadConf() (*dto.RedisConf, error)
|
LoadConf() (*dto.RedisConf, error)
|
||||||
|
|
@ -54,7 +54,7 @@ func (u *RedisService) UpdateConf(req dto.RedisConfUpdate) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *RedisService) ChangePassword(req dto.ChangeDBInfo) error {
|
func (u *RedisService) ChangePassword(req dto.ChangeRedisPass) error {
|
||||||
if err := updateInstallInfoInDB("redis", "", "password", true, req.Value); err != nil {
|
if err := updateInstallInfoInDB("redis", "", "password", true, req.Value); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4561,7 +4561,7 @@ const docTemplate = `{
|
||||||
"in": "body",
|
"in": "body",
|
||||||
"required": true,
|
"required": true,
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/dto.ChangeDBInfo"
|
"$ref": "#/definitions/dto.ChangeRedisPass"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
@ -11946,6 +11946,17 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"dto.ChangeRedisPass": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"value"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"value": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"dto.CleanLog": {
|
"dto.CleanLog": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
|
|
|
||||||
|
|
@ -4554,7 +4554,7 @@
|
||||||
"in": "body",
|
"in": "body",
|
||||||
"required": true,
|
"required": true,
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/dto.ChangeDBInfo"
|
"$ref": "#/definitions/dto.ChangeRedisPass"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
@ -11939,6 +11939,17 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"dto.ChangeRedisPass": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"value"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"value": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"dto.CleanLog": {
|
"dto.CleanLog": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
|
|
|
||||||
|
|
@ -163,6 +163,13 @@ definitions:
|
||||||
- groupID
|
- groupID
|
||||||
- id
|
- id
|
||||||
type: object
|
type: object
|
||||||
|
dto.ChangeRedisPass:
|
||||||
|
properties:
|
||||||
|
value:
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- value
|
||||||
|
type: object
|
||||||
dto.CleanLog:
|
dto.CleanLog:
|
||||||
properties:
|
properties:
|
||||||
logType:
|
logType:
|
||||||
|
|
@ -6925,7 +6932,7 @@ paths:
|
||||||
name: request
|
name: request
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/dto.ChangeDBInfo'
|
$ref: '#/definitions/dto.ChangeRedisPass'
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: OK
|
description: OK
|
||||||
|
|
|
||||||
|
|
@ -74,12 +74,11 @@ export const loadRedisConf = () => {
|
||||||
export const redisPersistenceConf = () => {
|
export const redisPersistenceConf = () => {
|
||||||
return http.get<Database.RedisPersistenceConf>(`/databases/redis/persistence/conf`);
|
return http.get<Database.RedisPersistenceConf>(`/databases/redis/persistence/conf`);
|
||||||
};
|
};
|
||||||
export const changeRedisPassword = (params: Database.ChangeInfo) => {
|
export const changeRedisPassword = (value: string) => {
|
||||||
let reqest = deepCopy(params) as Database.ChangeInfo;
|
if (value) {
|
||||||
if (reqest.value) {
|
value = Base64.encode(value);
|
||||||
reqest.value = Base64.encode(reqest.value);
|
|
||||||
}
|
}
|
||||||
return http.post(`/databases/redis/password`, reqest);
|
return http.post(`/databases/redis/password`, { value: value });
|
||||||
};
|
};
|
||||||
export const updateRedisPersistenceConf = (params: Database.RedisConfPersistenceUpdate) => {
|
export const updateRedisPersistenceConf = (params: Database.RedisConfPersistenceUpdate) => {
|
||||||
return http.post(`/databases/redis/persistence/update`, params);
|
return http.post(`/databases/redis/persistence/update`, params);
|
||||||
|
|
|
||||||
|
|
@ -114,16 +114,9 @@ const loadPassword = async () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
let param = {
|
|
||||||
id: 0,
|
|
||||||
from: 'local',
|
|
||||||
type: 'redis',
|
|
||||||
database: '',
|
|
||||||
value: form.value.password,
|
|
||||||
};
|
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
emit('closeTerminal');
|
emit('closeTerminal');
|
||||||
await changeRedisPassword(param)
|
await changeRedisPassword(form.value.password)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
|
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue