mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-09 01:13:41 +08:00
Fix bug in updateUserForOriginalFields().
This commit is contained in:
@ -106,7 +106,7 @@ func (syncer *Syncer) updateUser(user *OriginalUser) bool {
|
|||||||
|
|
||||||
func (syncer *Syncer) updateUserForOriginalFields(user *User) bool {
|
func (syncer *Syncer) updateUserForOriginalFields(user *User) bool {
|
||||||
owner, name := util.GetOwnerAndNameFromId(user.GetId())
|
owner, name := util.GetOwnerAndNameFromId(user.GetId())
|
||||||
oldUser := getUser(owner, name)
|
oldUser := getUserById(owner, name)
|
||||||
if oldUser == nil {
|
if oldUser == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -117,7 +117,7 @@ func (syncer *Syncer) updateUserForOriginalFields(user *User) bool {
|
|||||||
|
|
||||||
columns := syncer.getCasdoorColumns()
|
columns := syncer.getCasdoorColumns()
|
||||||
columns = append(columns, "affiliation", "hash", "pre_hash")
|
columns = append(columns, "affiliation", "hash", "pre_hash")
|
||||||
affected, err := adapter.Engine.ID(core.PK{user.Owner, user.Name}).Cols(columns...).Update(user)
|
affected, err := adapter.Engine.ID(core.PK{oldUser.Owner, oldUser.Name}).Cols(columns...).Update(user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -181,6 +181,24 @@ func getUser(owner string, name string) *User {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getUserById(owner string, id string) *User {
|
||||||
|
if owner == "" || id == "" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
user := User{Owner: owner, Id: id}
|
||||||
|
existed, err := adapter.Engine.Get(&user)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if existed {
|
||||||
|
return &user
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func GetUserByEmail(owner string, email string) *User {
|
func GetUserByEmail(owner string, email string) *User {
|
||||||
if owner == "" || email == "" {
|
if owner == "" || email == "" {
|
||||||
return nil
|
return nil
|
||||||
|
Reference in New Issue
Block a user