From c556affc919b24aca1a6d387f62c1a99df519930 Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Tue, 21 Mar 2023 18:44:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E5=AF=86=E7=A0=81=E4=BF=AE=E6=94=B9=E6=9C=AA=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E5=88=B0=E5=BA=94=E7=94=A8=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20(#343)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix: 解决数据库密码修改未同步到应用的问题 --- backend/app/repo/app_install.go | 5 +++++ backend/app/service/app_install.go | 9 +++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/backend/app/repo/app_install.go b/backend/app/repo/app_install.go index 79b526cff..cc0d61141 100644 --- a/backend/app/repo/app_install.go +++ b/backend/app/repo/app_install.go @@ -113,6 +113,7 @@ type RootInfo struct { Name string `json:"name"` Port int64 `json:"port"` Password string `json:"password"` + UserPassword string `json:"userPassword"` ContainerName string `json:"containerName"` Param string `json:"param"` Env string `json:"env"` @@ -146,6 +147,10 @@ func (a *AppInstallRepo) LoadBaseInfo(key string, name string) (*RootInfo, error if ok { info.Password = password } + userPassword, ok := envMap["PANEL_DB_USER_PASSWORD"].(string) + if ok { + info.UserPassword = userPassword + } info.Port = int64(appInstall.HttpPort) info.ID = appInstall.ID info.ContainerName = appInstall.ContainerName diff --git a/backend/app/service/app_install.go b/backend/app/service/app_install.go index 2d81c0e9c..1d6ff022d 100644 --- a/backend/app/service/app_install.go +++ b/backend/app/service/app_install.go @@ -3,9 +3,6 @@ package service import ( "encoding/json" "fmt" - "github.com/1Panel-dev/1Panel/backend/utils/env" - "github.com/1Panel-dev/1Panel/backend/utils/nginx" - "github.com/joho/godotenv" "io/ioutil" "math" "os" @@ -14,6 +11,10 @@ import ( "strconv" "strings" + "github.com/1Panel-dev/1Panel/backend/utils/env" + "github.com/1Panel-dev/1Panel/backend/utils/nginx" + "github.com/joho/godotenv" + "github.com/1Panel-dev/1Panel/backend/app/dto/request" "github.com/1Panel-dev/1Panel/backend/app/dto/response" "github.com/1Panel-dev/1Panel/backend/buserr" @@ -648,7 +649,7 @@ func updateInstallInfoInDB(appKey, appName, param string, isRestart bool, value }, commonRepo.WithByID(appInstall.ID)) } if param == "user-password" { - oldVal = fmt.Sprintf("\"PANEL_DB_USER_PASSWORD\":\"%v\"", appInstall.Password) + oldVal = fmt.Sprintf("\"PANEL_DB_USER_PASSWORD\":\"%v\"", appInstall.UserPassword) newVal = fmt.Sprintf("\"PANEL_DB_USER_PASSWORD\":\"%v\"", value) _ = appInstallRepo.BatchUpdateBy(map[string]interface{}{ "param": strings.ReplaceAll(appInstall.Param, oldVal, newVal),