Show properties in user page.

This commit is contained in:
Yang Luo
2021-05-30 18:35:05 +08:00
parent dc89f2b0f6
commit 11f1f8f440
7 changed files with 52 additions and 0 deletions

View File

@ -107,6 +107,22 @@ func SetUserProperty(user *User, field string, value string) bool {
return affected != 0
}
func ClearUserProperties(user *User, providerType string) bool {
for k := range user.Properties {
prefix := fmt.Sprintf("oauth_%s_", providerType)
if strings.HasPrefix(k, prefix) {
delete(user.Properties, k)
}
}
affected, err := adapter.Engine.ID(core.PK{user.Owner, user.Name}).Cols("properties").Update(user)
if err != nil {
panic(err)
}
return affected != 0
}
func calculateHash(user *User) string {
s := strings.Join([]string{user.Id, user.Password, user.DisplayName, user.Avatar, user.Phone}, "|")
return util.GetMd5Hash(s)