修复邮件发送密码为密文密码的Bug

随机生成的密码打印到日志
邮件通知发送明文密码
清理代码
This commit is contained in:
wsczx
2025-03-07 15:38:20 +08:00
parent 5e60feeb9b
commit 315e1deadc
9 changed files with 30 additions and 156 deletions

View File

@@ -120,7 +120,7 @@ func checkLocalUser(name, pwd, group string, ext map[string]interface{}) error {
}
pinCode := pwd
if base.Cfg.AuthAloneOtp == false {
if !base.Cfg.AuthAloneOtp {
// 判断otp信息
if !v.DisableOtp {
pinCode = pwd[:pl-6]
@@ -207,16 +207,18 @@ func CheckOtp(name, otp, secret string) bool {
// 插入数据库前加密密码
func (u *User) BeforeInsert() {
hashedPassword, err := utils.PasswordHash(u.PinCode)
if err != nil {
base.Error(err)
}
u.PinCode = hashedPassword
}
// 更新数据库前加密密码
func (u *User) BeforeUpdate() {
if len(u.PinCode) != 60 {
if base.Cfg.EncryptionPassword {
hashedPassword, err := utils.PasswordHash(u.PinCode)
if err != nil {
base.Error(err)
}
u.PinCode = hashedPassword
}
}
// 更新数据库前加密密码
func (u *User) BeforeUpdate() {
if len(u.PinCode) != 60 && base.Cfg.EncryptionPassword {
hashedPassword, err := utils.PasswordHash(u.PinCode)
if err != nil {
base.Error(err)