🐛修复初始化超管密码bug
All checks were successful
continuous-integration/drone/tag Build is passing

This commit is contained in:
coward
2024-05-09 10:30:46 +08:00
parent 8fb39958d2
commit 76470fa71b
2 changed files with 11 additions and 3 deletions

View File

@@ -1,6 +1,9 @@
package utils
import "golang.org/x/crypto/bcrypt"
import (
"gitee.ltd/lxh/logger/log"
"golang.org/x/crypto/bcrypt"
)
type password struct{}
@@ -26,5 +29,10 @@ func (password) GenerateHashPassword(pass string) string {
// @param pass
// @return bool
func (password) ComparePassword(dbPass, pass string) bool {
return bcrypt.CompareHashAndPassword([]byte(dbPass), []byte(pass)) == nil
if err := bcrypt.CompareHashAndPassword([]byte(dbPass), []byte(pass)); err != nil {
log.Errorf("密码错误: %v", err.Error())
return false
}
return true
}