mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-11-24 11:09:16 +08:00
fix: 初始化密码时,对密码进行加密操作 (#860)
This commit is contained in:
parent
c679631440
commit
1f2dfce7d1
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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');
|
||||
|
Loading…
Reference in New Issue
Block a user