This commit is contained in:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user