mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-02 03:00:18 +08:00
feat: User should have PasswordType like Organization (#1841)
* fixes #1840: [backend] User should have PasswordType like Organization is * Update migrator.go * Update and rename migrator_1_314_0_PR_1838.go to migrator_1_314_0_PR_1841.go * Update user.go --------- Co-authored-by: hsluoyz <hsluoyz@qq.com>
This commit is contained in:
@ -77,13 +77,17 @@ func GetUserByFields(organization string, field string) *User {
|
||||
}
|
||||
|
||||
func SetUserField(user *User, field string, value string) bool {
|
||||
bean := make(map[string]interface{})
|
||||
if field == "password" {
|
||||
organization := GetOrganizationByUser(user)
|
||||
user.UpdateUserPassword(organization)
|
||||
value = user.Password
|
||||
bean[strings.ToLower(field)] = user.Password
|
||||
bean["password_type"] = user.PasswordType
|
||||
} else {
|
||||
bean[strings.ToLower(field)] = value
|
||||
}
|
||||
|
||||
affected, err := adapter.Engine.Table(user).ID(core.PK{user.Owner, user.Name}).Update(map[string]interface{}{strings.ToLower(field): value})
|
||||
affected, err := adapter.Engine.Table(user).ID(core.PK{user.Owner, user.Name}).Update(bean)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user