mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 02:35:49 +08:00
Fix bug in updateUserForOriginalFields().
This commit is contained in:
parent
4b4c9be71b
commit
b60856be5e
@ -106,7 +106,7 @@ func (syncer *Syncer) updateUser(user *OriginalUser) bool {
|
||||
|
||||
func (syncer *Syncer) updateUserForOriginalFields(user *User) bool {
|
||||
owner, name := util.GetOwnerAndNameFromId(user.GetId())
|
||||
oldUser := getUser(owner, name)
|
||||
oldUser := getUserById(owner, name)
|
||||
if oldUser == nil {
|
||||
return false
|
||||
}
|
||||
@ -117,7 +117,7 @@ func (syncer *Syncer) updateUserForOriginalFields(user *User) bool {
|
||||
|
||||
columns := syncer.getCasdoorColumns()
|
||||
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 {
|
||||
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 {
|
||||
if owner == "" || email == "" {
|
||||
return nil
|
||||
|
Loading…
x
Reference in New Issue
Block a user