This commit is contained in:
parent
8fb39958d2
commit
76470fa71b
@ -79,7 +79,7 @@ func (s Script) CreateSuperAdmin() error {
|
||||
Name: "超牛管理员",
|
||||
Account: "Admin",
|
||||
Email: "",
|
||||
Password: utils.Password().GenerateHashPassword("admin123"),
|
||||
Password: "admin123",
|
||||
IsAdmin: constant.SuperAdmin,
|
||||
Status: constant.Normal,
|
||||
}); err != nil {
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user