diff --git a/backend/init/migration/migrations/init.go b/backend/init/migration/migrations/init.go index 70132e721..e6f5702ba 100644 --- a/backend/init/migration/migrations/init.go +++ b/backend/init/migration/migrations/init.go @@ -8,6 +8,7 @@ import ( "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/encrypt" "github.com/go-gormigrate/gormigrate/v2" "gorm.io/gorm" @@ -61,10 +62,13 @@ var AddTableSetting = &gormigrate.Migration{ if err := tx.AutoMigrate(&model.Setting{}); err != nil { return err } + encryptKey := common.RandStr(16) if err := tx.Create(&model.Setting{Key: "UserName", Value: global.CONF.System.Username}).Error; err != nil { return err } - if err := tx.Create(&model.Setting{Key: "Password", Value: global.CONF.System.Password}).Error; err != nil { + global.CONF.System.EncryptKey = encryptKey + pass, _ := encrypt.StringEncrypt(global.CONF.System.Password) + if err := tx.Create(&model.Setting{Key: "Password", Value: pass}).Error; err != nil { return err } if err := tx.Create(&model.Setting{Key: "Email", Value: ""}).Error; err != nil { @@ -97,7 +101,7 @@ var AddTableSetting = &gormigrate.Migration{ if err := tx.Create(&model.Setting{Key: "JWTSigningKey", Value: common.RandStr(16)}).Error; err != nil { return err } - if err := tx.Create(&model.Setting{Key: "EncryptKey", Value: common.RandStr(16)}).Error; err != nil { + if err := tx.Create(&model.Setting{Key: "EncryptKey", Value: encryptKey}).Error; err != nil { return err } diff --git a/backend/init/viper/viper.go b/backend/init/viper/viper.go index 3f91a22e7..660c1070b 100644 --- a/backend/init/viper/viper.go +++ b/backend/init/viper/viper.go @@ -107,9 +107,9 @@ func loadParams(param string) string { if err != nil { panic(err) } - baseDir := strings.ReplaceAll(stdout, "\n", "") - if len(baseDir) == 0 { + info := strings.ReplaceAll(stdout, "\n", "") + if len(info) == 0 || info == `""` { panic(fmt.Sprintf("error `%s` find in /usr/bin/1pctl", param)) } - return baseDir + return info } diff --git a/frontend/src/components/error-message/unsafe.vue b/frontend/src/components/error-message/unsafe.vue index 8ef1f225a..92ea972bf 100644 --- a/frontend/src/components/error-message/unsafe.vue +++ b/frontend/src/components/error-message/unsafe.vue @@ -22,7 +22,7 @@ import { MsgSuccess } from '@/utils/message'; const onCopy = () => { let input = document.createElement('input'); - input.value = '1pcth user-info'; + input.value = '1pctl user-info'; document.body.appendChild(input); input.select(); document.execCommand('Copy');