Improve syncer code.

This commit is contained in:
Yang Luo
2021-12-19 22:30:54 +08:00
parent e7f395cfd4
commit 5ee5299a68
8 changed files with 230 additions and 83 deletions

View File

@ -14,17 +14,15 @@
package object
import (
"strconv"
"strings"
"github.com/casbin/casdoor/cred"
"github.com/casbin/casdoor/util"
)
import "github.com/casbin/casdoor/cred"
func calculateHash(user *User) string {
s := strings.Join([]string{user.Id, user.Password, user.DisplayName, user.Avatar, user.Phone, strconv.Itoa(user.Score)}, "|")
return util.GetMd5Hash(s)
syncer := getDbSyncerForUser(user)
if syncer == nil {
return ""
}
return syncer.calculateHash(user)
}
func (user *User) UpdateUserHash() {