fix: use correct field name in user put api (#2026)
parent
06d9c03e92
commit
d94acdd89a
|
@ -177,7 +177,7 @@ var userPutHandler = withSelfOrAdmin(func(w http.ResponseWriter, r *http.Request
|
|||
}
|
||||
|
||||
for k, v := range req.Which {
|
||||
v = cases.Title(language.English).String(v)
|
||||
v = cases.Title(language.English, cases.NoLower).String(v)
|
||||
req.Which[k] = v
|
||||
|
||||
if v == "Password" {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package bolt
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
|
||||
"github.com/asdine/storm/v3"
|
||||
|
@ -58,7 +59,11 @@ func (st usersBackend) Update(user *users.User, fields ...string) error {
|
|||
}
|
||||
|
||||
for _, field := range fields {
|
||||
val := reflect.ValueOf(user).Elem().FieldByName(field).Interface()
|
||||
userField := reflect.ValueOf(user).Elem().FieldByName(field)
|
||||
if !userField.IsValid() {
|
||||
return fmt.Errorf("invalid field: %s", field)
|
||||
}
|
||||
val := userField.Interface()
|
||||
if err := st.db.UpdateField(user, field, val); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue