gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 3ab3f58342237664f7d28f047e3c2f88f97d3f11
parent 4fdbef04b4ae41e6193d4f4416c83edf91e1bfb7
Author: tobi <31960611+tsmethurst@users.noreply.github.com>
Date:   Fri,  5 Aug 2022 12:30:47 +0200

[bugfix] Parse source first before checking if empty form (#738)


Diffstat:
Minternal/api/client/account/accountupdate.go | 30+++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/internal/api/client/account/accountupdate.go b/internal/api/client/account/accountupdate.go @@ -144,21 +144,6 @@ func parseUpdateAccountForm(c *gin.Context) (*model.UpdateCredentialsRequest, er return nil, fmt.Errorf("could not parse form from request: %s", err) } - if form == nil || - (form.Discoverable == nil && - form.Bot == nil && - form.DisplayName == nil && - form.Note == nil && - form.Avatar == nil && - form.Header == nil && - form.Locked == nil && - form.Source.Privacy == nil && - form.Source.Sensitive == nil && - form.Source.Language == nil && - form.FieldsAttributes == nil) { - return nil, errors.New("empty form submitted") - } - // parse source field-by-field sourceMap := c.PostFormMap("source") @@ -178,5 +163,20 @@ func parseUpdateAccountForm(c *gin.Context) (*model.UpdateCredentialsRequest, er form.Source.Language = &language } + if form == nil || + (form.Discoverable == nil && + form.Bot == nil && + form.DisplayName == nil && + form.Note == nil && + form.Avatar == nil && + form.Header == nil && + form.Locked == nil && + form.Source.Privacy == nil && + form.Source.Sensitive == nil && + form.Source.Language == nil && + form.FieldsAttributes == nil) { + return nil, errors.New("empty form submitted") + } + return form, nil }