Skip to content

Commit

Permalink
[bugfix] Parse source first before checking if empty form (#738)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsmethurst committed Aug 5, 2022
1 parent 4fdbef0 commit 3ab3f58
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions internal/api/client/account/accountupdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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
}

0 comments on commit 3ab3f58

Please sign in to comment.