func HandleUpdateUser(
	u *graylog.User, lgc *logic.Logic,
	w http.ResponseWriter, r *http.Request, ps httprouter.Params,
) (interface{}, int, error) {
	// PUT /users/{username} Modify user details.
	userName := ps.ByName("username")
	if sc, err := lgc.Authorize(u, "users:edit", userName); err != nil {
		return nil, sc, err
	}
	body, sc, err := validateRequestBody(
		r.Body, &validateReqBodyPrms{
			Optional:     set.NewStrSet("email", "permissions", "full_name", "password", "timezone", "session_timeout_ms", "start_page", "roles"),
			Ignored:      set.NewStrSet("id", "preferences", "external", "read_only", "session_active", "last_activity", "client_address"),
			ExtForbidden: false,
		})
	if err != nil {
		return nil, sc, err
	}

	prms := &graylog.UserUpdateParams{Username: userName}
	if err := util.MSDecode(body, prms); err != nil {
		lgc.Logger().WithFields(log.Fields{
			"body": body, "error": err,
		}).Info("Failed to parse request body as UserUpdateParams")
		return nil, 400, err
	}
	sc, err = lgc.UpdateUser(prms)
	if err != nil {
		return nil, sc, err
	}
	if err := lgc.Save(); err != nil {
		return nil, 500, err
	}
	return nil, sc, nil
}
// HandleUpdateUser is the handler of Update User API.
HandleUpdateUser is the handler of Update User API.
// HandleUpdateUser is the handler of Update User API .
func HandleUpdateUser(
	u *graylog.User, lgc *logic.Logic,
	w http.ResponseWriter, r *http.Request, ps httprouter.Params,
) (interface{}, int, error) {
	userName := ps.ByName("username")
	if sc, err := lgc.Authorize(u, "users:edit", userName); err != nil {
		return nil, sc, err
	}
	body, sc, err := validateRequestBody(
		r.Body, &validateReqBodyPrms{
			Optional:     set.NewStrSet("email", "permissions", "full_name", "password", "timezone", "session_timeout_ms", "start_page", "roles"),
			Ignored:      set.NewStrSet("id", "preferences", "external", "read_only", "session_active", "last_activity", "client_address"),
			ExtForbidden: false,
		})
	if err != nil {
		return nil, sc, err
	}
	prms := &graylog.UserUpdateParams{Username: userName}
	if err := util.MSDecode(body, prms); err != nil {
		lgc.Logger().WithFields(log.Fields{
			"body": body, "error": err,
		}).Info("Failed to parse request body as UserUpdateParams")
		return nil, 400, err
	}
	sc, err = lgc.UpdateUser(prms)
	if err != nil {
		return nil, sc, err
	}
	if err := lgc.Save(); err != nil {
		return nil, 500, err
	}
	return nil, sc, nil
}
func HandleUpdateUser ( u * graylog . User , lgc * logic . Logic , w http . ResponseWriter , r * http . Request , ps httprouter . Params , ) ( interface { } , int , error ) { userName := ps . ByName ( " " ) if sc , err := lgc . Authorize ( u , " " , userName ) ; err != nil { return nil , sc , err } body , sc , err := validateRequestBody ( r . Body , & validateReqBodyPrms { Optional : set . NewStrSet ( " " , " " , " " , " " , " " , " " , " " , " " ) , Ignored : set . NewStrSet ( " " , " " , " " , " " , " " , " " , " " ) , ExtForbidden : false , } ) if err != nil { return nil , sc , err } prms := & graylog . UserUpdateParams { Username : userName } if err := util . MSDecode ( body , prms ) ; err != nil { lgc . Logger ( ) . WithFields ( log . Fields { " " : body , " " : err , } ) . Info ( " " ) return nil , 400 , err } sc , err = lgc . UpdateUser ( prms ) if err != nil { return nil , sc , err } if err := lgc . Save ( ) ; err != nil { return nil , 500 , err } return nil , sc , nil }
HandleUpdateUser is the handler of Update User API.
HandleUpdateUser is the handler of Update User API .
// PUT /users/{username} Modify user details.