graph: Allow PATCH on user without 'mail' in body

Skip the mail validator if 'mail' attribute is not present in the
request.
This commit is contained in:
Ralf Haferkamp
2022-03-23 15:44:58 +01:00
parent a99f725c00
commit 517356f176
2 changed files with 12 additions and 5 deletions
+6
View File
@@ -0,0 +1,6 @@
Bugfix: Fix request validation on GraphAPI User updates
Fix PATCH on graph/v1.0/users when no 'mail' attribute
is present in the request body
https://github.com/owncloud/ocis/issues/3167
+6 -5
View File
@@ -180,11 +180,12 @@ func (g Graph) PatchUser(w http.ResponseWriter, r *http.Request) {
return
}
mail := changes.GetMail()
if !isValidEmail(mail) {
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest,
fmt.Sprintf("'%s' is not a valid email address", mail))
return
if mail, ok := changes.GetMailOk(); ok {
if !isValidEmail(*mail) {
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest,
fmt.Sprintf("'%s' is not a valid email address", *mail))
return
}
}
u, err := g.identityBackend.UpdateUser(r.Context(), nameOrID, *changes)