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

This commit is contained in:
tobi 2022-08-05 12:30:47 +02:00 committed by GitHub
parent 4fdbef04b4
commit 3ab3f58342
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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