mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-05 19:59:37 -06:00
graph/users: gracefully handle PATCH requests with empty bodies
Return as success status code when the PATCH request comes with an empty body. This is mainly to workaround issues like: https://github.com/owncloud/web/issues/8946
This commit is contained in:
committed by
Ralf Haferkamp
parent
1ad31218ec
commit
77e773515d
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
@@ -130,6 +131,13 @@ func (g Graph) PatchGroup(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if reflect.ValueOf(*changes).IsZero() {
|
||||
logger.Debug().Interface("body", r.Body).Msg("ignoring empyt request body")
|
||||
render.Status(r, http.StatusNoContent)
|
||||
render.NoContent(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
if changes.HasDisplayName() {
|
||||
groupName := changes.GetDisplayName()
|
||||
err = g.identityBackend.UpdateGroupName(r.Context(), groupID, groupName)
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
@@ -646,6 +647,13 @@ func (g Graph) PatchUser(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if reflect.ValueOf(*changes).IsZero() {
|
||||
logger.Debug().Interface("body", r.Body).Msg("ignoring empyt request body")
|
||||
render.Status(r, http.StatusNoContent)
|
||||
render.NoContent(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
var features []events.UserFeature
|
||||
if mail, ok := changes.GetMailOk(); ok {
|
||||
if !isValidEmail(*mail) {
|
||||
|
||||
Reference in New Issue
Block a user