From 3ab3f58342237664f7d28f047e3c2f88f97d3f11 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Fri, 5 Aug 2022 12:30:47 +0200 Subject: [PATCH] [bugfix] Parse source first before checking if empty form (#738) --- internal/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 index 7fae681d2..786aefb38 100644 --- 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 }