[bugfix] Parse source first before checking if empty form (#738)
This commit is contained in:
parent
4fdbef04b4
commit
3ab3f58342
|
@ -144,21 +144,6 @@ func parseUpdateAccountForm(c *gin.Context) (*model.UpdateCredentialsRequest, er
|
||||||
return nil, fmt.Errorf("could not parse form from request: %s", err)
|
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
|
// parse source field-by-field
|
||||||
sourceMap := c.PostFormMap("source")
|
sourceMap := c.PostFormMap("source")
|
||||||
|
|
||||||
|
@ -178,5 +163,20 @@ func parseUpdateAccountForm(c *gin.Context) (*model.UpdateCredentialsRequest, er
|
||||||
form.Source.Language = &language
|
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
|
return form, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue