密码加密开关

This commit is contained in:
孤鸿 2025-03-07 04:39:22 +00:00
parent 33b2c4890b
commit ccd7093bd2
1 changed files with 12 additions and 10 deletions

View File

@ -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)