This commit is contained in:
2024-08-01 02:44:06 +08:00
parent 1860e3666d
commit a8891902c6
11 changed files with 121 additions and 57 deletions

View File

@@ -46,6 +46,9 @@ func (a *Account) SetPassword(password string) error {
// 验证登录帐户密码合法性
func (a *Account) CheckPassword() bool {
password := a.Password
aa, err1 := bcrypt.GenerateFromPassword([]byte(a.Password), 12)
print(aa, err1)
DB.Where("username = ?", a.Username).First(&a)
err := bcrypt.CompareHashAndPassword([]byte(a.Password), []byte(password))
return err == nil